@DTS Engineer
I will give it a try with the latest beta of iOS 18 and Xcode 16. In the meantime, what is the suggested workaround? Because what I'm doing is this:
extension ModelContainer {
static var myContainer: ModelContainer {
print("ModelContainer | myContainer called")
let schema = Schema([
CDShift.self
])
let cloudConfiguration = ModelConfiguration(
isStoredInMemoryOnly: Ecosystem.current.isPreview,
groupContainer: .identifier(Ecosystem.current.appGroupIdentifier),
cloudKitDatabase: .automatic
)
let localConfiguration = ModelConfiguration(
nil,
schema: schema,
isStoredInMemoryOnly: Ecosystem.current.isPreview,
groupContainer: .identifier(Ecosystem.current.appGroupIdentifier),
cloudKitDatabase: .none
)
do {
let container: ModelContainer
if let cloudContainer = try? ModelContainer(
for: schema,
migrationPlan: MigrationPlan.self,
configurations: cloudConfiguration) {
AMLogger.verbose("Cloud container created, CloudKit is enabled!")
container = cloudContainer
} else {
AMLogger.verbose("Cloud container failed to create, we will now create a local container and then again a cloud container.")
_ = try ModelContainer(
for: schema,
migrationPlan: MigrationPlan.self,
configurations: localConfiguration
)
container = try ModelContainer(
for: schema,
migrationPlan: MigrationPlan.self,
configurations: cloudConfiguration
)
AMLogger.verbose("Cloud container created after local one.")
}
AMLogger.verbose("SwiftData path: \(container.configurations.first!.url.path)")
return container
} catch (let error) {
fatalError("Could not create ModelContainer: \(error)")
}
}
}
I try to create a cloud container and, if it fails, I create a local one to perform the migration, then try again to create the cloud one. The issue is that it seems that the version of the schema keeps staying on "1.0.0".