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

没有这样的模块

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

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

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


当前回答

我在加载FacebookSDK时遇到了类似的问题,我添加了~/Documents/FacebookSDK(搜索你的框架在哪里)到构建设置中的框架搜索路径,之后我就可以导入FBSDKShareKit模块了

其他回答

对我来说,解决同样问题的方法是相对于工作空间目录设置派生数据位置,而不是保持默认值。 去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.

我得到了相同的错误

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添加到任何适当的占位符。

确保项目文件夹不在iCloud Drive中。

如果你是面向tvOS这样的平台创造游戏,请确保你选择了一个Apple TV模拟器。

使用iOS模拟器创建tvOS应用时,我就犯了这个错误。花了大半个小时寻找各种构建问题……哎。