I have some potential progress, but due to the nature of this crash, I don't know if this is correct or not.
After inspecting the sqlite-files that represents the backingdata, I discovered that a property backed by an integer was set to null after migration even the original value was 3.
Upon inspection, I realized this was the very first property I ever migrated, so it was still annotated with @Attribute(orginalName: "propertyName"), even tho the migration which crashed for me was the 9th migration step overall for the app.
Thus, with the Schema I was migrating from being:
struct SchemaV7 {
@Model
class Item {
@Attribute(originalName: "propertyName")
var newPropertyName: Int
}
}
And then removing it in the destination Schema:
struct SchemaV8 {
@Model
class Item {
var newPropertyName: Int
}
}
made me able to complete the migration without crashing.
Wether this was the solution or not, I have no idea, but it could explain some of the crashes I've seen earlier...
The property which was crashing the app have never been optional, but the sqlite column driving the backingstore was set to optional, which explains the crash. It doesn't however explain the data loss on migration
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags: