Swift Realm:创建Realm实例会引发NSException

时间:2016-04-24 11:07:17

标签: ios swift realm

OSX 10.11,  Swift 2.2, Realm 0.99

我使用Carthage安装了Realm。

let realm = try! Realm() 会抛出NSException

libc++abi.dylib:以NSException

类型的未捕获异常终止

项目编译,构建并运行直到Realm实例化。 两个Realm框架文件都在项目的嵌入式二进制文件和嵌入式框架中。 它们位于Carthage / Build / IOS文件夹中。 它们也出现在链接二进制文件中,与构建阶段的库部分一起出现。

非常感谢帮助。

领域安装:

Install Carthage 0.9.2 or later.
Add github "realm/realm-cocoa" to your Cartfile.
Run carthage update.

Drag RealmSwift.framework and Realm.framework from the appropriate platform directory in Carthage/Build/ to the “Embedded Binaries” section of your Xcode project’s “General” settings.

iOS/watchOS/tvOS: On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. 
Create a Run Script with the following contents:

/usr/local/bin/carthage copy-frameworks

and add the paths to the frameworks you want to use under “Input Files”, e.g.:

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

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

1 个答案:

答案 0 :(得分:1)

哦亲爱的,问题是班级中的非可选声明。 不知道为什么不能被抓住。浪费时间。