【问题标题】:Build realm for Swift 3 & Xcode 8为 Swift 3 和 Xcode 8 构建领域
【发布时间】:2016-08-01 10:19:24
【问题描述】:

我正在按照here 的步骤构建要在 iOS 项目中使用的领域,我使用的是 Xcode 8 beta 3:

我收到这些警告:

ld: warning: ignoring file .../Realm.framework/Realm, missing required architecture x86_64 in file .../Realm.framework/Realm (2 slices)
ld: warning: ignoring file .../RealmSwift.framework/RealmSwift, missing required architecture x86_64 in file .../RealmSwift.framework/RealmSwift (2 slices)

还有这个错误

Lipo: -remove's specified would result in an empty fat file

为什么会这样?

【问题讨论】:

  • 嗨 Carpsen90,我刚刚意识到您链接到了一些方向。您愿意分享您正在使用的 Xcode 8 测试版吗?另外,在 Xcode --> Preferences menu --> Locations 选项卡中,您是否选择了 Xcode 8.0 命令行工具?
  • @AustinZ 我使用的是 Xcode 8 beta 3,命令行设置为 Xcode 8

标签: swift realm


【解决方案1】:

您可以试试这些更新后的说明,它们应该适用于 Beta 3 吗?

  1. 克隆 Realm Cocoa git 存储库:git clone https://github.com/realm/realm-cocoa.git
  2. 打开 Xcode 项目。单击Realm 项目,然后单击RealmSwift 目标,然后单击“构建设置”选项卡,并将Use Legacy Swift Language Version 设置为Yes(如果为Swift 2.3 构建)或No(如果为Swift 3 构建) .
  3. 从包含 git 存储库的目录中,运行以下命令:sh build.sh TARGET,其中 TARGET 是以下之一:ios-swift、osx-swift、tvos-swift 或 watchos-swift,具体取决于什么您正在构建的平台。
  4. 构建完成后,转到“build”目录,然后转到以您构建的平台命名的目录(例如“ios”)。
  5. 打开“swift-2.3”或“swift-3.0”目录(取决于您构建的版本)。
  6. 将RealmSwift.framework 和Realm.framework 拖到您的项目中,按照here 说明中的第2 步,然后执行第3 步和第4 步。

如果这些不起作用,请发表评论。

【讨论】:

  • 有没有一种简单的方法可以将其集成到carthage 工作流程中?
  • 没有更多的编译错误,但我得到这个运行时错误 dyld: Library not loaded: @rpath/libswiftCore.dylib Referenced from: .../Library/Developer/CoreSimulator/Devices/761AECC6-C62D-4AE0-90EB-518A91736F3D/data/Containers/Bundle/Application/D7FFF785-CD14-46CF-A7A4-B0648B822FAF/RealmApp.app/RealmApp Reason: image not found
  • @catalandres 我将研究如何与 Carthage 合作。
  • @AustinZ 是的,我已经做到了,感谢您抽出宝贵时间,非常感谢
  • 得到这个:clang:错误:没有这样的文件或目录:'/Users/mike/Projects/realm-cocoa/Realm/ObjectStore/src/impl/weak_realm_notifier.cpp' clang:错误:没有输入文件**构建失败**
【解决方案2】:

为了获得Realm 和RealmSwift 的Swift 3 版本,我必须明确定位master,将submodules 设置为true,和 包括post_install设置 Swift 版本的钩子:

use_frameworks!

target 'TARGET_NAME' do
    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'] = '3.0'
            end
        end
    end
end

【讨论】:

  • 这对我有用,也避免了我在仅指定 pod 'RealmSwift' 和安装后挂钩时遇到的编译错误。我认为 Realm 网站应该使用这些说明更新文档。谢谢
【解决方案3】:

您需要使用 Cocoapods 和这个 pod 安装 Realm:

pod 'Realm',git:'https://github.com/realm/realm-cocoa.git',分支:'master'

pod 'RealmSwift',git:'https://github.com/realm/realm-cocoa.git',分支:'master'

并且在运行应用程序时不要选择转换为 swift 3

【讨论】:

  • 试过但得到了这个If you're using Realm and/or RealmSwift from a git branch, please add 'submodules: true' to their entries in your Podfile.所以我添加了:submodules => true。该项目已经在 Swift 3 中,所以我无法降级代码
  • 所以在运行应用程序并忽略编译器错误时,我得到了这个“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
  • 是的,但我忽略了它,并且一直在正常使用 Realm,在我的情况下它可以工作。
  • 在您的情况下,基础项目没有转换为 Swift 3 对吗?
  • 基础项目已转换,但领域 pod 未转换。
猜你喜欢
  • 1970-01-01
  • 2016-12-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多