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:

  • How to get Main Window (App Delegate) from other class (subclass of NSViewController)?
  • Picking a Random Object in an NSArray
  • Adjust screen brightness in Mac OS X app
  • Re-initialize a lazy initialized variable in Swift
  • NSNotificationCenter : list of observers?
  • Can't use reloadData from another class
  • 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?

    Solutions Collect From Internet About “Swift app: “Missing required module” when importing framework that imports static library”

    Select your Target, then go into Build Settings and set the Import Paths within the Swift CompilerSearch 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..