首页 文章

Swift项目:导入模块化框架时“缺少必需的模块”

提问于
浏览
6

Setup

  • 我创建了一个包含C库(CommonCrypto)和Objective C文件的swift框架 .

  • swift项目中没有bridge-header . 所以我创建了一个 module.modulemap 来将CommonCrypto和Objective-C文件导入到我的swift框架中 .

module.modulemap内容:
enter image description here

这是module.modulemap示例链接:Importing CommonCrypto in a swift framework

  • 在项目设置中,将modulus.modulusmap路径添加到swift编译
    enter image description here

所以,在我的快速框架中,一切正常 . 我可以像这样使用模数

enter image description here

Problem shows

  • 归档模块化框架并导出为内置产品 .

  • 在我的swift示例项目中,将模块化框架添加到嵌入式二进制文件
    enter image description here

  • Error occurs on this line when I use something inside the framework
    enter image description here

我尝试了很多解决方案,但仍然没有用 .

类似的问题:

Swift应用程序:导入静态库的框架时“缺少必需的模块”添加RealmSwift作为子项目:缺少必需的模块:'Realm.Private','Realm'

有人有一个很好的解决方案吗?谢谢!!

1 回答

  • 3

    Solution

    iOS框架作为文件夹存在,创建 module.modulemap 以查找库或头文件 .

    • 设置 module.modulemap 路径

    在项目/目标/构建设置/ Swift编译 - 搜索路径/导入路径=“$

    • 以下添加到 module.modulemap

    enter image description here

    Remarks

    如果框架在同一开发环境中存档,则不必将module.modulemap添加到示例项目 .

相关问题