I have an app in the app store which is working fine. Some users reported that they have app crashing when they are using iOS 17.4 beta. I could recreate the issue and it is happening when ModelContainer is crerated. This code..
do {
let configuration = ModelConfiguration(for: MyTodo.self, isStoredInMemoryOnly: false)
modelContainer = try ModelContainer(for: MyTodo.self, configurations: configuration)
} catch {
fatalError("Failed to load model container.\(error)")
}
is throwing this error message:
Fatal error: Failed to load model container.SwiftDataError(_error: SwiftData.SwiftDataError._Error.loadIssueModelContainer)
My model do not have any @Attribute(.unique) All properties have default values Relationships are marked as optional App is using CloudKit for iCloud syncronization
A brandnew app with the same model does not have this issue. When I uncheck "CloutKit" in Signing & Capabilities, the app launch normally.
Widget can obtain the data without error/crash from modelContainer using this code:
I have now identified that this issue is happening due to Relationships in my model. My MyToDo has task defined like this:
and MyTask has reference back as following:
Both of them are optional as required for CloudKit. This model can be read in iOS 17.3, but in 17.4 beta, it crashes!