testing realm, cannot add a new property to my testing class. Followed documentation and some answer here but both are not working. In my code even the "plain" empty default block for migration is not working, using updated realm.
getting this error
Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=10 "Migration is required due to the following errors: - Property 'ComicType.creationDate' has been added." UserInfo={NSLocalizedDescription=Migration is required due to the following errors: - Property 'ComicType.creationDate' has been added., Error Code=10}
it seems I'm not changing the schemaVersion, but I did in the "basic" migration block. I check the schema version in app delegate with:
let configCheck = Realm.Configuration();
do {
let fileUrlIs = try schemaVersionAtURL(configCheck.fileURL!)
print("schema version \(fileUrlIs)")
} catch {
print(error)
}
my AppDelegate:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let config = Realm.Configuration(schemaVersion: 1, migrationBlock: { migration, oldSchemaVersion in
if (oldSchemaVersion < 1) {
}
})
Realm.Configuration.defaultConfiguration = config
_ = try! Realm()
return true
}
my class:
import Foundation
import RealmSwift
class ComicType: Object {
@objc dynamic var name : String = ""
@objc dynamic var creationDate : Date? //the new property
}
schemaVersionjust needs to be 1? Is this your first migration? - Dávid Pásztor