Swift项目:“缺少必需的模块”导入模块化框架时 [英] Swift Project: "Missing Required Modules" when import a modular framework

查看:1899
本文介绍了Swift项目:“缺少必需的模块”导入模块化框架时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设置


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


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



    模块。 modulemap内容:


这是模块.modulemap示例链接:



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




问题显示


  1. 存档模块化框架和导出为内置产品。


  2. 在我的swift示例项目中,将模块化框架添加到嵌入式二进制文件


  3. 当我在框架内使用某些内容时,此行发生错误


我尝试了很多解决方案,但仍然无法正常工作。



Sim问题:





  1. 备注



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


    Setup

    1. I create a swift framework which include C library (CommonCrypto) and a Objective C file.

    2. 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.

      module.modulemap content:

    Here is the module.modulemap sample link:Importing CommonCrypto in a swift framework

    1. 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

    1. Archive the modular framework and export as a built products.

    2. In my swift sample project, add modular framework to Embedded Binaries

    3. Error occurs on this line when I use something inside the framework

    I have try so many solutions, but still not work.

    Similar problems:

    1. Swift app: "Missing required module" when importing framework that imports static library

    2. Adding RealmSwift as a subproject: Missing required modules: 'Realm.Private', 'Realm'

    Is anyone have a good solution for this? Thx!!

    解决方案

    Solution

    iOS framework exists as a folder, create a module.modulemap to find out library or header file.

    1. Setup module.modulemap path

      In project/target/Build Settings/Swift Compile - Search Path/Import Path = "${SRCROOT}"

    2. Add below to 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.

    这篇关于Swift项目:“缺少必需的模块”导入模块化框架时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆