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

没有这样的模块

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

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

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


当前回答

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

错误是“模块未找到”

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)

这是所有。

其他回答

如果工作区中有多个项目,则需要:

向所有项目添加新配置 产品->清洁 删除派生数据 终端吊舱安装 构建您的项目。

我也遇到过这个问题。对我来说,修复是两个项目之间的存档方案不匹配。我有一个xcworkspace与框架项目和应用程序项目。问题在于,在我的应用程序的存档方案中,我使用了与框架的存档方案不同的构建配置。我把两个构建配置都设置为发布,这就解决了这个问题。

在podfile中,删除产生问题的pod,并保存该文件 运行pod安装 重新添加pod,保存文件 重新运行pod安装

我用

链接的框架和库

将框架添加到Workspace文件夹的顶部。讨厌鬼。

如果你使用CocoaPods,试着注释掉(#)新的pod,运行pod install,把它带回来,然后再次安装pod。有时somewhy pod脚本不能产生正确的依赖关系(或者与运行xCode冲突?)所以它有时确实有帮助