简体   繁体   English

通过Obj-C桥接头将sqlite3.h导入Swift项目不起作用

[英]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.

相关问题 当我在swift中导入OBJ-C类时,Xcode不会提示我添加一个Bridging-header.h - When I import OBJ-C classes in swift, Xcode doesn't prompt me to add a Bridging-header.h 通过桥接头导入Obj-C文件后出错 - Errors after importing Obj-C files through bridging header Swift 桥接头和 Obj-C 类的可见性 - Swift Bridging Header and visibility of Obj-C class 从Swift 2项目中删除Obj-C桥接头后的错误 - Errors after removing Obj-C Bridging Header from Swift 2 Project 未找到Swift / Obj-C桥接标头/导入失败 - Swift/Obj-C bridging header not found/failed to import # 通过自动创建的Bridging header 导入的Obj-C 类,Bridging header 似乎找到了但Swift 类不会 - # Imported Obj-C class through automatically created Bridging header, Bridging header seems to find it but Swift class won't Objective-C桥接问题。 如何在Swift项目中使用Obj-C框架? - Objective-C bridging issue. How do I use an Obj-C framework in a Swift project? 无法导入导入Project-Swift.h的Swift桥接头Objective-C文件 - Can't import into Swift bridging header Objective-C file that imports Project-Swift.h 在Swift项目中使用Objective-C文件。 在桥接头文件中导入头文件会导致#import“ Module-Swift.h”失败 - Using an Objective-C file in Swift project. Importing the header file in the bridging header causes the `#import “Module-Swift.h”` to fail 如何通过迦太基在Obj-C项目中使用Swift库 - How to use Swift library in Obj-C project via Carthage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM