Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
755 views
in Technique[技术] by (71.8m points)

macos - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...