2

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.

3
  • Have you added sqlite3 framework by Build Phase-> Link binary->Sqlite3.. in your project? Commented Jan 18, 2016 at 8:20
  • Can you add #import < sqlite3.h > in your Bridging-Header.h file: Commented Jan 18, 2016 at 8:31
  • 1
    In framework you can't use Bridging-Header. It will give error. <unknown>:0: error: using bridging headers with framework targets is unsupported Commented Jan 18, 2016 at 9:04

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

Comments

0

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.

2 Comments

how to make it public? When I go to build phrases and try to include sqlite3.h it shows only "sqlite3.tbd"
same problem. How can I make it public?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.