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

没有这样的模块

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

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

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


当前回答

大多数其他答案都是针对CocoaPods或迦太基用户的。如果你不使用这些,但只是想在你的项目中删除一个框架并链接它,它将需要在框架搜索路径中。

系统框架已经在搜索路径(即/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/ sdk/ iPhoneOS${version}.sdk/ system /Library/ frameworks /)。如果您试图使用的文件不在此路径中,则需要将它们的路径添加到Build Settings中的FRAMEWORK_SEARCH_PATHS中。


为什么XCode不知道在哪里找到它,即使你左边面板上的框架在右边面板的标识和类型中列出了一个位置和完整的路径?那我不知道。

其他回答

我用

链接的框架和库

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

当我使用Cocoapods添加两个框架时,我得到了相同的错误。如果我们在项目中使用Pods,我们应该使用xcodeworkspace而不是xcodeproject。 为了通过xcodebuild运行项目,我在xcodebuild命令中添加了-workspace <workspacename>参数,它工作得很好。

对我来说,编辑方案->运行,并将调试配置从发布更改为调试解决问题。

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

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

Another possible cause in XCode 10 can be the Supported Platforms sometimes gets changed to macOS and the Valid Architectures gets changed to i386 x86_64 for the Pods Projects. Assuming the project is for iOS, then select the Pods Project and change the Supported Platforms to iOS and the Valid Architectures to arm64 arm64e armv7 armv7s, You could do each of the Targets, however that takes longer if you have more than one Pod. Also the Swift version of frameworks in written Swift sometimes gets set to the wrong version.