Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift app: “Missing required module” when importing framework that imports static library

Here’s my setup:

  1. Static library of Objective C code called Stat.
  2. A Swift framework that uses code from Stat in its own classes (this framework is called Dyn). The static library and this framework are in the same Xcode project.
  3. A Mac app / project that has the above project as a subproject and which links to Dyn.

In my app I have code like:

import Cocoa import Dyn ... SomeDynClass().doSomething() 

However, when I try to compile I get an error when I import Dyn. The error is

error: missing required module ‘Stat' 

It appears my app can find my framework just fine, but it somehow needs to find a module for my static library, too?

Stat has a module file that’s pretty basic:

module Stat {     header "Stat.h"     export * } 

I think I need to point my Mac app’s framework search paths at Stat but I don’t know why and I don’t know how. How do I solve this?

like image 291
jbrennan Avatar asked Aug 01 '15 01:08

jbrennan


2 Answers

Select your Target, then go into Build Settings and set the Import Paths within the Swift Compiler - Search Paths section:

${SRCROOT}/Stat 

Normally the module would be named the same as the library, however, I'm not sure how you've setup the directory with the module.map (it could be named Dyn perhaps, in which case the Import Path would reflect that name.

Build Settings > Swift Compiler > Search Paths:

enter image description here

${SRCROOT}/(directory with module.map) should resolve itself once you press enter or tab..

like image 120
l'L'l Avatar answered Sep 21 '22 20:09

l'L'l


I got the same error when in my unit tests project which involves SQLite3 package. After I add the package, unit tests always throw out error saying "missing required module SQLiteObjc"

I had it fixed by toggle "Force Package Info Generation" on and off in my Unit Tests Target's build setting

like image 29
Tomasen Avatar answered Sep 17 '22 20:09

Tomasen