I don't know if I'm missing something here.
I got a crash after running my app without a migration block after updating a property (same problem as here Realm Migration not working)
But now when I run the app, it must run the migration because it no longer crashes but my object's properties are not updated.
I have updated the below object ("minReps" is the one I've added):
class ExerciseGeneratorObject: Object {
@objc dynamic var name = ""
@objc dynamic var minReps = 0
@objc dynamic var maxReps = 0
convenience init(name: String, minReps: Int, maxReps: Int) {
self.init()
self.name = name
self.minReps = minReps
self.maxReps = maxReps
}
Then I'm running an empty migration block like this in appDelegate :
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let config = Realm.Configuration(
schemaVersion: 3,
migrationBlock: { migration, oldSchemaVersion in
if (oldSchemaVersion < 3) {
}
})
Realm.Configuration.defaultConfiguration = config
let realm = try! Realm()
I thought Realm was meant to update object properties automatically if you run an empty migration block - is that wrong? Am I missing some code to make this work?
There's a very similar problem here (Realm migrations in Swift) (the isn't me!) but looks out of date now (and sure I've tried the solutions there as above!)