【问题标题】:Realm Swift 2.2.0: No Such Module "RealmSwift" in Xcode 8Realm Swift 2.2.0:Xcode 8 中没有这样的模块“RealmSwift”
【发布时间】:2017-01-14 20:01:51
【问题描述】:

我尝试通过 cocoapods 使用 RealmSwift,但我收到没有这样的模块“RealmSwift”错误。

pod 安装成功,安装 Realm 2.2.0

我已经尝试过干净的构建和构建文件夹以及派生数据 我还创建了一个虚拟项目并进行了全新安装,但它仍然无法正常工作。 当我尝试导入 RealSwift 并构建时,构建成功,但之后又出现错误。

这是我的 Podfile

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'RealmDummyProject' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!

# Pods for RealmDummyProject
 pod 'RealmSwift'

 post_install do |installer|
  installer.pods_project.targets.each do |target|
   target.build_configurations.each do |config|
     config.build_settings['SWIFT_VERSION'] = '3.0' # or '3.0'
   end
  end
 end

end

我正在使用带有 Swift 3.0 的 Xcode 版本 8.1 (8B62) 谢谢!

【问题讨论】:

  • “当我尝试导入 RealSwift 并构建时,构建成功,但之后又出现错误。” – 这是否意味着您能够编译和运行应用程序?
  • 是,首次启动工作区时
  • 在这种情况下,Xcode 可能只是缓存了一些以前的错误,请尝试清理项目和构建文件夹,重新启动 Xcode 等并重建应用程序。

标签: realm


【解决方案1】:

使用 CocoaPods 生成的 .xcworkspace 文件而不是 .xcodeproj 来处理您的项目。而且,我相信你的PodFile 应该是这样的:

来自领域Installation

如果使用 Xcode 8,请将以下内容粘贴到 Podfile 的 bottom...

target 'RealmDummyProject' do
  use_frameworks!

  # Pods for RealmDummyProject
  pod 'RealmSwift'
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '3.0'
    end
  end
end

此外,这可能会对您有所帮助: RealmSwift installation on Xcode

【讨论】:

  • 谢谢@jch-duran,但这不是问题,我的 Podfile 是正确的。
【解决方案2】:

刚刚遇到类似问题。

您应该在打开.xcworkspace 文件后立即“编译项目”。

因为看起来如果您是第一次使用特定的 Pod,XCode 直到您编译整个工作区才知道它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-04
    • 2016-07-11
    • 2017-05-15
    • 1970-01-01
    • 2020-10-23
    相关资源
    最近更新 更多