我目前在Swift编码,我有一个错误:

没有这样的模块

但我不明白,因为这个模块在我的项目中,在“链接框架和库”和“嵌入式二进制文件”中声明。

框架是在Objective-C中,所以我为它写了一个桥标头。

请问,如何让Xcode识别框架?


当前回答

Sazzad Hissain Khan的3分。选项添加相同的“构建配置”在应用程序的框架,而不是在应用程序解决了我的“未知模块”问题。

这篇文章帮助我了解如何添加新的构建配置,因为进入编辑器->添加配置是灰色的

在Xcode中添加构建配置

其他回答

为了它的价值(我是使用Xcode 7.2/Swift 2的新手),但我注意到,只要从项目目录中的库中拥有. Swift文件,就可以自动地访问它,而不需要using语句。

示例:我正在使用SwiftyJSON,在项目中拥有SwiftyJSON.swift文件就是我所需要的。using语句实际上给了我“没有这样的模块”错误,并把它解决了,它工作得很好。

我发现构建设置中的导入路径是错误的自定义(MySQL)模块。把它指向正确的方向后,信息就消失了。

几天前我也遇到了同样的错误。下面是我解决这个问题的方法:

错误是“模块未找到”

Create Podfile in your root project directory Install cocoapods (a dependency manager for Swift and iOS projects) Run pod install Go to Project Build Settings: Find Objective-c bridging Header under Swift compiler - Code Generation (If you don't find Swift compiler here, probably add a new Swift file to the project) Drag and drop the library header file from left side to bridging header (see image attached) Create a new bridging header file: e.g TestProject-Bridging-Header.h and put under Swift Compiler → Objective-C Generated Interface Header Name (ref, see the image above) In TestProject-Bridging-Header.h file, write #import "Mixpanel/Mixpanel.h" In your Swift file the code should be: Import Mixpanel (i.e name of library)

这是所有。

在我的例子中,问题只是一些使用框架的项目在框架的部署目标iOS版本之前有一个部署目标iOS版本。一旦我更改了框架部署目标iOS版本,错误就消失了。

我得到这个问题是因为我在podfile中设置了错误的目标(项目本身而不是UITests部分)。