我目前在Swift编码,我有一个错误:
没有这样的模块
但我不明白,因为这个模块在我的项目中,在“链接框架和库”和“嵌入式二进制文件”中声明。
框架是在Objective-C中,所以我为它写了一个桥标头。
请问,如何让Xcode识别框架?
我目前在Swift编码,我有一个错误:
没有这样的模块
但我不明白,因为这个模块在我的项目中,在“链接框架和库”和“嵌入式二进制文件”中声明。
框架是在Objective-C中,所以我为它写了一个桥标头。
请问,如何让Xcode识别框架?
当前回答
以我为例,在多次尝试找出导入框架时哪里做错了之后,我最终发现问题出在框架本身。如果你不是从一个可信的来源获得你的框架,你应该检查框架并确保它包含一个模块的Modules文件夹。其中的Modulemap文件。如果模块。modulemap不存在,你会得到“No such module 'MyFramework'”错误。
如果Modules文件夹缺少“MyFramework.”然后框架就会被找到,但是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.
如果你是面向tvOS这样的平台创造游戏,请确保你选择了一个Apple TV模拟器。
使用iOS模拟器创建tvOS应用时,我就犯了这个错误。花了大半个小时寻找各种构建问题……哎。
我得到了相同的错误
import Firebase
但随后注意到,我没有将pod添加到主目标部分,而只是在Podfile中添加到Test和TestUI目标。
用命令
pod init
对于xcode swift项目,会生成以下Podfile
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'MyApp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for MyApp
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'MyAppUITests' do
inherit! :search_paths
# Pods for testing
end
end
因此,需要确保将pod添加到任何适当的占位符。
我安装了pod Fakery, pod被添加到我的Pods文件下,但是当我尝试使用它时,我得到了同样的错误。问题是,我没有构建它,在构建它之后,swift编译器在Fakery swift文件中抛出了一些错误,一些函数已经被重命名,它也为它们提供了修复。在解决了所有这些编译器问题后,构建成功了,我能够使用模块。所以快速的语言兼容性是我的问题。
我在使用Cocoapods和Swift时也遇到了同样的问题。我没有注意到Podfile中的以下行:
# Uncomment this line if you're using Swift
# use_frameworks!
所以,我所要做的就是把它改成:
# Uncomment this line if you're using Swift
use_frameworks!
...啊,它起作用了:)