gpt4 book ai didi

swift - Realm Swift OS X Cocoapods 示例应用程序崩溃

转载 作者:搜寻专家 更新时间:2023-10-30 21:55:15 25 4
gpt4 key购买 nike

我的步骤是:

1) 在 Xcode 中,我创建了一个新的命令行 OS X Swift 应用程序并添加了他们的示例“class Dog”代码,并在顶部添加了“import RealmSwift”。

2) 我添加了一个包含两行的 Podfile,“use_frameworks!”和“pod 'RealmSwift'”,然后运行 ​​pod install。

3) 我打开工作区,编译并运行。我收到此警告:

Not running swift-stdlib-tool: EMBEDDED_CONTENT_CONTAINS_SWIFT is enabled, but the product type 'Command-line Tool' is not a wrapper type.

这次崩溃:

dyld: Library not loaded: @rpath/libswiftAppKit.dylib Referenced from: /Users/ys1382/Library/Developer/Xcode/DerivedData/testRealmApp-gxysfwfiirxwddbklmbolznecnld/Build/Products/Debug/RealmSwift.framework/Versions/A/RealmSwift Reason: image not found

到目前为止,谷歌搜索表明警告和崩溃是相关的。有什么建议吗?

我正在使用 OS X El Capitan、Xcode 7.2.1、Cocoapods 0.39.0

最佳答案

TiM 的评论让我发现,在撰写本文时,几乎不可能将框架添加到 Swift 命令行应用程序。 This blog post描述了一种方式。从第 1 步开始,它说:

  1. Create an Objective-C command line tool and change the Search Paths. Not Swift. You can create a Swift framework for the code you’d put in your command line tool, but the tool itself must not compile any Swift code. Doing so will confuse the linker and make it see duplicate declarations of the Swift library (one in the shipped .dylib, another embedded in the command line tool).

This presentation展示了一种不同的方法,从创建 Cocoa 应用程序开始,然后通过 31 个步骤将其强制转换为命令行应用程序。

就在那个时候,我想,“也许我的命令行工具毕竟可以使用一些漂亮的图形”,并制作了一个 Cocoa OSX Swift Realm Cocoapod 应用程序,这很有效。

关于swift - Realm Swift OS X Cocoapods 示例应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35423862/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com