Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift Project: "Missing Required Modules" when import a modular framework

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: enter image description here

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

  1. In project settings, adding modulus.modulusmap path to swift compileenter image description here

    So, in my swift framework, everything works fine. I can use modulus like this

    enter image description here

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 enter image description here

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

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!!

like image 311
HungCLo Avatar asked Feb 07 '17 08:02

HungCLo


1 Answers

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

enter image description here

Remarks

You don't have to add module.modulemap to the sample project if the framework is archived on the same development environment.

like image 90
HungCLo Avatar answered Oct 17 '22 07:10

HungCLo