我目前在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.

其他回答

我不知道为什么会发生这种情况,但解决你的问题的一种方法是进入你的构建设置并定义框架搜索路径到一个包含有问题的框架的文件夹。如果框架放在您的项目目录中,只需将框架搜索路径设置为$(SRCROOT)并将其设置为递归。

此错误也可能由框架缺少模块映射引起。如果您试图导入的框架是您自己的框架,请检查框架本身的编译器警告。在我的情况下,我的框架正在构建和到位,但有一个构建警告:

警告:没有为目标'MyFramework'找到伞头,模块映射将不会生成

通过解决这个警告(与框架头不匹配模块名有关),我能够导入框架。

在General =>链接框架和库中,我添加了。/Pods/Pods。Xcodeproj成功了

我在使用Cocoapods和Swift时也遇到了同样的问题。我没有注意到Podfile中的以下行:

# Uncomment this line if you're using Swift
# use_frameworks!

所以,我所要做的就是把它改成:

# Uncomment this line if you're using Swift
use_frameworks!

...啊,它起作用了:)

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

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


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