【问题标题】:Realm using xCode 8 & Swift 2.3 Failing使用 xCode 8 和 Swift 2.3 的领域失败
【发布时间】:2016-09-23 14:36:53
【问题描述】:

我最近更新到 xCode 8,我选择继续使用 Swift 2.3

我正在使用 Cocoapods 来集成 Realm,它在升级到 xCode 8 之前就可以工作。

我在 Realm 的 GitHub 上四处搜索并尝试了一些解决方案,但均未成功。 在我的 podfile 中,Realm 有以下几行

pod 'Realm', git: 'https://github.com/realm/realm-cocoa.git', branch: 'master', submodules: true
pod 'RealmSwift', git: 'https://github.com/realm/realm-cocoa.git', branch: 'master', submodules: true

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

安装成功完成并显示消息:

使用 Realm (1.1.0) 使用 RealmSwift (1.1.0)

当我重新启动我的应用程序时:

  • 68 条文件丢失警告RLM* Files
  • 错误 - Umbrella header 'Realm.h not found
  • 错误 - Cound not build Objective-C module Realm

【问题讨论】:

  • 您是否尝试过使用桥接头?
  • @cloudcal 不,您建议如何使用它?过去我不必使用桥接头。
  • Realm 不需要标头
  • @Alan 您是否确保在 Pod 下将 User Legacy Swift Language 版本设置为“YES”?如果未指定,可能会导致您的问题。

标签: ios swift xcode cocoapods realm


【解决方案1】:

我遇到了完全相同的问题,并通过将我的“用户旧版 Swift 语言版本”设置为该 Pod 的“是”来解决它。

【讨论】:

    【解决方案2】:

    我也遇到了同样的问题。我的 Podfile 看起来和你的相似,但我有这个编辑:

    pod 'Realm', git: 'https://github.com/realm/realm-cocoa.git', branch: 'master', submodules: true
    pod 'RealmSwift', '~> 2.3.0'
    
    post_install do |installer|
        installer.pods_project.targets.each do |target|
          target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '2.3'
       end
      end
    end
    

    As of v2.4.0, Swift 2.x is no longer supported.Realm 2.3.0 是最后一个支持 Swift 2.3 的稳定版本。同样正如 Soundshock 所说,确保 RealmSwift Pod 目标的“用户旧版 Swift 语言版本”为“是”。希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-31
      • 1970-01-01
      相关资源
      最近更新 更多