xcode Swift 项目:导入模块化框架时“缺少必需的模块”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42085217/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Swift Project: "Missing Required Modules" when import a modular framework
提问by HungCLo
Setup
设置
I create a swift framework which include C library (CommonCrypto) and a Objective C file.
There is no bridge-header in swift project. So I create a
module.modulemap
to import CommonCrypto and Objective-C file into my swift framework.
我创建了一个 swift 框架,其中包括 C 库(CommonCrypto)和一个 Objective C 文件。
swift 项目中没有桥头文件。所以我创建了一个
module.modulemap
将 CommonCrypto 和 Objective-C 文件导入我的 swift 框架。
Here is the module.modulemap sample link:Importing CommonCrypto in a swift framework
这是 module.modulemap 示例链接:Importing CommonCrypto in a swift framework
In project settings, adding modulus.modulusmap path to swift compile
So, in my swift framework, everything works fine. I can use modulus like this
Problem shows
问题显示
Archive the modular framework and export as a built products.
In my swift sample project, add modular framework to Embedded Binaries
Error occurs on this line when I use something inside the framework
I have try so many solutions, but still not work.
我已经尝试了很多解决方案,但仍然不起作用。
Similar problems:
类似问题:
Is anyone have a good solution for this? Thx!!
有没有人对此有好的解决方案?谢谢!!
回答by HungCLo
Solution
解决方案
iOS framework exists as a folder, create a module.modulemap
to find out library or header file.
iOS 框架作为一个文件夹存在,创建一个module.modulemap
来查找库或头文件。
Setup
module.modulemap
pathIn project/target/Build Settings/Swift Compile - Search Path/Import Path = “${SRCROOT}”
Add below to
module.modulemap
设置
module.modulemap
路径在 project/target/Build Settings/Swift Compile - Search Path/Import Path = “${SRCROOT}”
在下面添加到
module.modulemap
Remarks
评论
You don't have to add module.modulemap to the sample project if the framework is archived on the same development environment.
如果框架存档在同一开发环境中,则不必将 module.modulemap 添加到示例项目中。