这是我的设置:
Stat 的 Objective C 代码静态库。Stat 代码的 Swift 框架(这个框架称为 Dyn)。静态库和这个框架在同一个 Xcode 项目中。Dyn 的 Mac 应用程序/项目。在我的应用程序中,我有如下代码:
import Cocoa
import Dyn
...
SomeDynClass().doSomething()
但是,当我尝试编译时,我在 import Dyn 时遇到错误。错误是
error: missing required module ‘Stat'
看起来我的应用程序可以很好地找到我的框架,但它也需要为我的静态库找到一个模块?
Stat 有一个非常基本的模块文件:
module Stat {
header "Stat.h"
export *
}
我想我需要将我的 Mac 应用程序的框架搜索路径指向 Stat,但我不知道为什么,也不知道如何做。我该如何解决这个问题?
最佳答案
选择您的Target,然后进入Build Settings 并在Swift Compiler 中设置Import Paths - 搜索路径部分:
${SRCROOT}/Stat
通常,模块的名称与库的名称相同,但是,我不确定您是如何使用 module.map 设置目录的(它可以命名为 Dyn 也许,在这种情况下,导入路径将反射(reflect)该名称。
build设置 > Swift 编译器 > 搜索路径:
${SRCROOT}/(directory with module.map) should resolve itself once you press enter or tab..
关于macos - swift 应用程序 : “Missing required module” when importing framework that imports static library,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31757417/