Realm-cocoa: try! Realm() crash

Created on 10 Apr 2017  路  4Comments  路  Source: realm/realm-cocoa

Hello,
I try to add with cocoapods, and doing simple things.
add "let realm = try! Realm()" in viewDidLoad
add to appDelegate "Realm.Configuration.defaultConfiguration.deleteRealmIfMigrationNeeded = true"
But then crash happened, i have no clue. Desperate here

Actual Results

"libc++abi.dylib: terminating with uncaught exception of type NSException"

Code Sample

Realm framework version: 2.5.1

Xcode version: 8.2

iOS/OSX version: 10.2

T-Help

Most helpful comment

If anyone else encounters this- I placed try Realm() in a do-try-catch and printed the NSError, and I realized it was failing because I had added new properties to one of my Realm objects, so I needed to migrate. So I just deleted my realm file (in Finder, outside of code), since I didn't need to preserve any data. This error was crashing Xcode entirely, which is kind of weird behavior.

All 4 comments

Hi @danlniel. Thanks for reaching out about this. Would you be able to provide us with a sample project that demonstrates the issue? From there, we'll be able to determine if this has to do with Realm or if it has to do with another side effect in the project.

You can either post a zip of the project here or share it confidentially via email to [email protected].

it might be useful to see what the error is by doing a do-try-catch instead of forcing a try!, then print out the error

If anyone else encounters this- I placed try Realm() in a do-try-catch and printed the NSError, and I realized it was failing because I had added new properties to one of my Realm objects, so I needed to migrate. So I just deleted my realm file (in Finder, outside of code), since I didn't need to preserve any data. This error was crashing Xcode entirely, which is kind of weird behavior.

I was having the same problem and later on I realized I had a mistake when I was setting new properties to one of my Realm objects.

Was this page helpful?
0 / 5 - 0 ratings