I have a SwiftUI + SwiftData (with iCloud) app. The setup code is standard, with schema migrations (mostly lightweight, one custom). Everything works correctly except in one scenario.
When I run a newer version of the app (with an updated schema adding one field + migration) on a device with the previous data container (the usual app version update through TestFlight), I encounter an issue on the first launch. The app crashes on the first "cold" start but runs successfully on subsequent launches.
The error I receive on the first run is:
addPersistentStoreWithType:configuration:URL:options:error: returned error NSCocoaErrorDomain (134060)
NSLocalizedFailureReason : Unable to find a configuration named 'default' in the specified managed object model.
What might be a problem and how to resolve it?