Keshav Raj
Keshav Raj

Reputation: 219

Using sqlite in framework

I am creating a framework in swift and I need to use sqlite.

I've imported #import <sqlite3.h> to use it and I am writing it in .h file created by Xcode.

But while building, I am getting this error:

"include of non modular header inside framework module".

I have searched for this question but couldn't find an appropriate answer that solves my problem.

Upvotes: 2

Views: 3071

Answers (2)

Aaron Bratcher
Aaron Bratcher

Reputation: 6451

To use SQLite in a custom framework, you need to include the sqlite3.h file directly into the project and then make that file public.

  • To get the .h file, right-click on Xcode and select "show package contents"
  • In the search bar, type "sqlite3.h"
  • Select Xcode in the search area

Finder Search

  • Drag the file to your project and choose "Copy items if needed"
  • Select the sqlite3.h file in your project navigator
  • In the utilities pane, change target membership to public.

xcode

In your umbrella header file, make sure you add this line:

#include "sqlite3.h"

(Don't use the <sqlite3.h> form as you're now including the file from your project)

You may notice that the umbrella header automatically adds the line #import <UIKit/UIKIt.h> as shown below. If you don't need UIKit, then remove that line.

Umbrella header

You can find a full example here: https://github.com/AaronBratcher/ALBNoSQLDB

Upvotes: 4

Keshav Raj
Keshav Raj

Reputation: 219

What I was missing was adding sqlite3.h explicitly. It won't be automatically added when you add libsqlite3.tbd library. Make sqlite3.h public and then import it as umbrella header.

Upvotes: 0

Related Questions