Swift 应用程序:导入导入静态库的框架时“缺少必需的模块" [英] Swift app: “Missing required module” when importing framework that imports static library
问题描述
这是我的设置:
- Objective C 代码的静态库,称为
Stat
. - 一个 Swift 框架,它在自己的类中使用来自
Stat
的代码(这个框架被称为Dyn
).静态库和这个框架在同一个 Xcode 项目中. - 将上述项目作为子项目并链接到
Dyn
的 Mac 应用/项目.
- Static library of Objective C code called
Stat
. - A Swift framework that uses code from
Stat
in its own classes (this framework is calledDyn
). The static library and this framework are in the same Xcode project. - 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()
然而,当我尝试编译时,当我import Dyn
时出现错误.错误是
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
有一个非常基本的模块文件:
Stat
has a module file that’s pretty basic:
module Stat {
header "Stat.h"
export *
}
我想我需要将我的 Mac 应用程序的框架搜索路径指向 Stat
,但我不知道为什么,也不知道怎么做.我该如何解决这个问题?
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?
推荐答案
选择您的 Target
,然后进入 Build Settings
并设置 Import Paths
Swift Compiler
- Search Paths
部分中的 code>:
Select your Target
, then go into Build Settings
and set the Import Paths
within the Swift Compiler
- Search Paths
section:
${SRCROOT}/Stat
通常,模块的名称与库的名称相同,但是,我不确定您是如何使用 module.map
设置目录的(它可以命名为 Dyn
也许,在这种情况下,导入路径将反映该名称.
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.
构建设置>Swift 编译器搜索路径:
${SRCROOT}/(directory with module.map) 应该自己解决一次您按 Enter 或 Tab 键..
${SRCROOT}/(directory with module.map) should resolve itself once you press enter or tab..
这篇关于Swift 应用程序:导入导入静态库的框架时“缺少必需的模块"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!