Swift应用程序:“导入静态库时导入框架时缺少必需的模块” [英] Swift app: “Missing required module” when importing framework that imports static library
问题描述
这里是我的设置:
- Objective C代码的静态库叫
Stat
。 - 一个Swift框架使用自己类中的
Stat
代码(此框架称为Dyn
)。 - 将上述项目作为子项目并链接到
Dyn 的Mac应用程序/项目。 code>。
在我的应用程序中,我有如下代码:
import Cocoa
然而,当我尝试编译时,我得到一个错误,当我
import Dyn
...
SomeDynClass()。doSomething()
import Dyn
。错误是错误:缺少所需的模块'Stat'
看来我的应用程序可以找到我的框架很好,但它不知何故需要找到一个我的静态库的模块?
Stat
有一个非常基本的模块文件:module Stat {
headerStat.h
export *
}
$ b b我想我需要指向我的Mac应用程序的框架搜索路径
Stat
,但我不知道为什么,我不知道如何。如何解决这个问题?解决方案选择您的
目标
到Build Settings
并在Swift编译器
导入路径 > -搜索路径
部分:$ {SRCROOT} / Stat
通常模块的命名方式与库的命名方式相同,使用
module.map
(可能命名为Dyn
)来设置目录,在这种情况下,导入路径
构建设置> Swift编译器>搜索路径
$ {SRCROOT} /(包含module.map的目录)
您按Enter键或Tab ..
Here’s my setup:
- 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()
However, when I try to compile I get an error when I
import Dyn
. The error iserror: 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?解决方案Select your
Target
, then go intoBuild Settings
and set theImport Paths
within theSwift 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 namedDyn
perhaps, in which case the Import Path would reflect that name.Build Settings > Swift Compiler > Search Paths:
${SRCROOT}/(directory with module.map) should resolve itself once you press enter or tab..
这篇关于Swift应用程序:“导入静态库时导入框架时缺少必需的模块”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!