[英]Importing sqlite3.h to a Swift project via a Obj-C bridging header doesn't work
I have created a file called BridgingHeader.h
and it contains only one line: 我创建了一个名为
BridgingHeader.h
的文件,它只包含一行:
#import <sqlite.h>
And of course the framework libsqlite3.dylib
is imported either. 当然,框架
libsqlite3.dylib
也是导入的。
In my build settings I've also set the value of Objective-C Bridging Header to <ProjectName>/Bridging-Header.h
在我的构建设置中,我还将Objective-C Bridging Header的值设置为
<ProjectName>/Bridging-Header.h
BUT… 但…
When I add import sqlite3
to my Swift class it says that it cannot find the module sqlite3
. 当我将
import sqlite3
添加到我的Swift类时,它说它无法找到模块sqlite3
。
For anyone who does want to use SQLite 3 directly, see this Gist: 对于想要直接使用SQLite 3的任何人,请参阅此要点:
https://gist.github.com/zgchurch/3bac5443f6b3f407fe65 https://gist.github.com/zgchurch/3bac5443f6b3f407fe65
Thanks to @trojanfoe I am using now a library which is an Objective-C
wrapper for the sqlite3
framework. 感谢@trojanfoe我现在正在使用一个库,它是
sqlite3
框架的Objective-C
包装器。 ( FMDB ) ( FMDB )
Got it to work by importing the ObjC
header in my BridgingHeader.h
file and using the class without importing anything in the Swift
class. 通过在我的
BridgingHeader.h
文件中导入ObjC
头并使用该类而不在Swift
类中导入任何内容来实现它。
Conclusion: Only Objective-C files can be imported into the bridging header… 结论:只能将Objective-C文件导入桥接头...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.