swift - 使用 carthage 的 RealmSwift 框架集成问题

标签 swift realm versioning carthage

我已经使用 carthage 依赖工具集成了 RealmSwift 框架。

我已按照以下步骤操作:

  1. 安装 Carthage 0.17.0 或更高版本

  2. 将 github“realm/realm-cocoa”“master”添加到您的 Cartfile。

  3. 运行迦太基更新。要修改用于构建的 Swift 工具链,请通过 --toolchain 参数指定它。例如:

迦太基更新--toolchain com.apple.dt.toolchain.Swift_2_3

  • 将 RealmSwift.framework 和 Realm.framework 从 Carthage/Build/中相应的平台目录拖到 Xcode 项目“常规”设置的“嵌入式二进制文件”部分。

  • iOS/tvOS/watchOS:在应用程序目标的“构建阶段”设置上 选项卡,单击“+”图标并选择“新运行脚本阶段”。创建一个 运行包含以下内容的脚本:

  • /usr/local/bin/carthage 复制框架 并在“输入文件”下添加您要使用的框架的路径,例如:

    $(SRCROOT)/Carthage/Build/iOS/Realm.framework $(SRCROOT)/Carthage/Build/iOS/RealmSwift.framework

    现在,

    当我尝试构建我的项目时,我收到此错误:

    使用 Swift 3.0 编译的模块无法导入到 Swift 2.3 中:Carthage/Build/iOS/RealmSwift.framework/Modules/RealmSwift.swiftmodule/x86_64.swiftmodule

    我不知道问题出在哪里。

    最佳答案

    来自Installation section in Docs :

    The --no-use-binaries argument is also necessary to avoid Carthage pulling the prebuilt Swift 3.0 binaries.

    因此第 3 步的命令应如下所示

    carthage update --toolchain com.apple.dt.toolchain.Swift_2_3 --no-use-binaries
    

    (猜测您在主项目中使用 Swift 2.3)

    关于swift - 使用 carthage 的 RealmSwift 框架集成问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40995221/

    相关文章:

    ios - 多任务处理时如何获取屏幕尺寸?

    ios - 使用 Realm Mobile Platform 处理照片

    swift - 在迁移期间删除属性

    Flutter 版本解决失败 with new flutter upgrade

    web-applications - 在 Web 应用程序的页脚中显示底层软件的版本?

    backup - 自动文件版本控制(例如Dropbox)

    ios - 点击推送通知时打开浏览器

    ios - NSTemporaryDirectory 或 documentDirectory : Which one is safest to store data?

    swift - 将 [[UIColor]] 双数组转换为 UIImage

    ios - 如何将 RealmSwift 列表转换为结果?