SwiftData migration with iCloud and multi-device support

I’m writing test apps using SwiftData. Running migrations locally works fine. But I couldn’t find anything on how to handle a situation, where my local app is running on e.g. ‘MigrationSchemaV2’ and an iOS app is still running on ‘MigrationSchemaV1’ hence needs to be updated before the data migration takes place.

I expect the local migration to be synced to iCloud automatically therefore the iOS app would crash.

I’m looking for documentation, tutorials, best practice or lessons learned in order to understand the basic implementation idea, its dependencies and implications.

It is a requirement that when you use CloudKit, your schemas are always backwards compatible for this exact reason. Your schema on CloudKit might be V2 but your user hasn't updated yet so their device is still on V1. Or, like in your example, you have 2 devices syncing but one is V1 and the other is V2.

Thanks for the answer. Do you also know where I might find more information as I mentioned in my question above? I haven't implemented such scenario so far and some documentation in order to get a better understanding of what has to be done and how would be helpful.

SwiftData migration with iCloud and multi-device support
 
 
Q