Using sqlite in framework

戏子无情 提交于 2019-12-24 00:54:13

问题


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.


回答1:


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

  • 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.

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.

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




回答2:


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.



来源:https://stackoverflow.com/questions/34849464/using-sqlite-in-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!