这是我的设置:
Stat
.Stat
的代码(这个框架称为 Dyn
).静态库和这个框架在同一个 Xcode 项目中.Dyn
的 Mac 应用程序/项目.Stat
.Stat
in its own classes (this framework is called Dyn
). The static library and this framework are in the same Xcode project.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}/(module.map 的目录) 应该自己解析一次你按 enter 或 tab ..
${SRCROOT}/(directory with module.map) should resolve itself once you press enter or tab..
这篇关于Swift 应用程序:导入静态库的框架时“缺少必需的模块"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!