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

没有这样的模块

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

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

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


当前回答

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.

其他回答

在目标的构建设置中,将“框架搜索路径”设置为$(inherited)和递归。 [

对于Xcode 10+和项目,还有一个建议。创建Xcode版本< 10,2。包含带有主项目所依赖的框架的子项目。问题是Xcode会将编译后的框架放在子项目中指定的目录中,这可能与主项目的构建目录不同。

检查文件>项目设置。现在,单击“Advanced…”并选择“Legacy”以外的内容作为构建路径,例如,“Unique”。在这种情况下,Xcode将把所有构建的组件放到一个文件夹中,它应该能够找到“丢失”的模块。

在我的情况下,项目上的swift 4库没有编译,所以不可能找到它们并导入。 解决方案是将cocoapods库的编译版本设置为swift 3.2

几分钟前我找到了解决我案子的办法。 该项目是一个使用cocos2d框架的objective c项目。 没有一个预览解决方案有效。

只是我删除VALID_ARCH行自定义在构建设置和项目开始构建模拟器。

请将此截图与您的构建设置进行比较。 这可能会奏效。 进入框架搜索路径: