Swift应用程序:“导入静态库时导入框架时缺少必需的模块” [英] Swift app: “Missing required module” when importing framework that imports static library

查看:1479
本文介绍了Swift应用程序:“导入静态库时导入框架时缺少必需的模块”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是我的设置:


  1. Objective C代码的静态库叫 Stat

  2. 一个Swift框架使用自己类中的 Stat 代码(此框架称为 Dyn )。

  3. 将上述项目作为子项目并链接到 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:

  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?

解决方案

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:

${SRCROOT}/(directory with module.map) should resolve itself once you press enter or tab..

这篇关于Swift应用程序:“导入静态库时导入框架时缺少必需的模块”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆