将第三方 C 库导入 swift 导致错误“Include of non-modular header inside framework module" [英] Import third party C library into swift causes error "Include of non-modular header inside framework module"
问题描述
这个问题是
感谢任何帮助,提前感谢您!
我对混合语言框架从来没有 100% 确定.但是像这样的错误会在 Swift 项目中发生:
- 由于您不能在框架中使用桥接头,
- 你
#import
在Foo-Framework.h
中添加一个 C 头文件来公开它,以便 Swift 代码,以及 - 标头本身并未对目标标记为公开".
非模块化"似乎表示不是已发布模块接口的一部分".至少对于 Swift--C 混合,你只能通过公开 C 头文件来组合两者;没有办法在那里导入私有头文件,这很奇怪.
试一试:由于您显然是在非 Swift 代码中导入文件,请尝试在您的 Xcode 项目中找到 export.h
头文件,打开文件检查器 (⌘⌥1),并确保框架目标中的公众可见性:
This question is a continuation of a previous one I'm currently migrating this (https://github.com/emilwojtaszek/leveldb-swift) library from swift 2 to swift 3/4. Here is the link to my fork https://github.com/lu4/leveldb-swift/tree/MigrationFromSwift2ToSwift3 (please note that the target branch is MigrationFromSwift2ToSwift3)
I was able to resolve (with many thanks to @Ruslan Serebriakov) all of the issues with initial code base and check that the code is running.
However after trying to update LevelDB C code to latest master I got new type of error which I don't understand how to resolve:
Include of non-modular header inside framework module 'LevelDB.c': '/Path/to/Project/leveldb-swift-migration/vendor/leveldb/include/leveldb/export.h'
I've did some research on the internet but the issues described there seem non-related with one I've stumbled on. Here is an image of the issue
Any help is appreciated, thank you in advance!
I'm never 100% certain with mixed language frameworks. But an error like this happens in Swift projects when:
- since you cannot use a Bridging Header in frameworks,
- you
#import
a C header in theFoo-Framework.h
to expose it so the Swift code, and - the header is not itself marked "Public" to the target.
"Non-modular" seems to indicate "not part of the published module interface". At least with Swift--C mixes, you can only combine both through making the C headers public; no way to import private header files there, which is weird.
Give it a shot: Since you are obviously importing the file in non-Swift code, try to locate the export.h
header file in your Xcode project, open the File inspector (⌘⌥1), and ensure public visibility in the framework target:
这篇关于将第三方 C 库导入 swift 导致错误“Include of non-modular header inside framework module"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!