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

没有这样的模块

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

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

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


当前回答

假设框架真的在那里,在道路上,等等……删除~/Library/Developer/Xcode/DerivedData/ModuleCache目录(清理项目并删除项目特定的派生数据)。

在执行标准清理时,不会重新构建ModuleCache目录。

其他回答

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

错误是“模块未找到”

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)

这是所有。

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

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

对我来说,问题在于项目文件缺少这个文件“coursesX.xcworkspace”

当我添加它并重新打开项目时,一切都工作得很好

您将依赖项(模块)添加到pod中,但没有版本(特定或范围)。 请定义版本,运行pod install,并打开。xcworkspace文件,而不是。xcodeproj文件

检查你是否使用最新版本的xcode。(如果没有更新到您设备支持的最新版本)。 用sudo gem Install cocoapods安装cocoapods 运行吊舱设置

我可以确认以上步骤解决了我的错误:-)