Hello, first of all, thank you for your reply. The headache of this problem is that it cannot be reproduced in Xcode. However, I seem to have found some clues recently. In
enum MeSchemaV5: VersionedSchema {
...
}
, I listed all the Model definition codes. But outside this enum, I also defined all the Models (all the codes are exactly the same), and did not use typealias to specify the Model. I guess it may be due to this reason that when the ModelContainer is initialized, the Model of the schema all points to the Model outside the enum, and the Model corresponding to SchemaV5 is not found during the execution of MigraitonPlan, so the error "Error.loadIssueModelContainer" is reported.
I tried to delete the Model definition code outside the enum and use typealias to specify the corresponding Model.
typealias HealthDataList = MeSchemaV5.HealthDataList
typealias HealthDataStatistics = MeSchemaV5.HealthDataStatistics
typealias HeartZoneData = MeSchemaV5.HeartZoneData
typealias UserSettingTypeFor = MeSchemaV5.UserSettingTypeFor
typealias SleepDataSource = MeSchemaV5.SleepDataSource
...
The problem seems to have improved. Most of the time, the migration operation can be completed normally without crashes. However, there are still a small number of users who report that "Error.loadIssueModelContainer" sometimes appears. But I'm not sure if it is related to this.
At the same time, I don't know if you can provide a sample code on how to use MigraitonPlan correctly. There is really little content in the official documentation for this area. I hope to get your help to learn how to use MigraitonPlan correctly, as well as some related precautions.
In addition, I have never encountered the error you mentioned, "error: Attempting to retrieve an NSManagedObjectModel version checksum while the model is still editable. This may result in an unstable verison checksum. Add model to NSPersistentStoreCoordinator and try again.". However, when I initialized ModelContainer using the new method, this error appeared and can be reproduced in Xcode. How do I submit a feedback report?
Finally, thank you again for your help.