I do the following inside didFinishLaunchingWithOptions:
let config = Realm.Configuration(
schemaVersion: 0,
deleteRealmIfMigrationNeeded: true
)
Realm.Configuration.defaultConfiguration = config
let realm = try! Realm()
Basically, during development, I don’t want to worry about migration and just want to clear the database whenever the schema changes. I understand what exactly for deleteRealmIfMigrationNeeded.
The problem is that sometimes, when Realm initialization fails, it crashes with the following error :
fatal error: 'try!' expression unexpectedly caused an error: Error Domain = io.realm Code = 5 "Directory on the way" / Users / rock / Library / Developer / CoreSimulator / Devices / D626848E-14D5-47AC-8FFB-9B67D024DEF1 / data / Containers / Data / Application / 6F71103C-9E10-4131-BED4-D96445FABA52 / Documents / default.realm 'does not exist.
default.realm , - deleteRealmIfMigrationNeeded, ( ) Realm .
, default.realm.lock, , .
? ? ( Realm Swift 2.4.1)