CoreDate->SwiftData Migration & CloudKit

I have an existing CoreData + CloudKit app which I would like to migrate to SwiftData + CloudKit.

In the existing CoreData implementation, I have many optional fields (most of which have default values). I want to migrated them to SwiftData non-optional fields with default values.

Can someone please confirm that I can do this without causing issues for my existing (CoreData + CloudKit) customers? I.e., I know I can do the migration on the local copy of the database, but I am worried about the CloudKit interaction.

Specifically, I'm concerned about properties such as

var title: String?

which is implemented in CloudKit as

CD_title
CD_title_ckAsset

Can I safely implement this in SwiftData as

var title: String = ""

without causing a problem with the CloudKit implementation?

Using a non-optional SwiftData attribute with SwiftData+CloudKit should work. Both String and String? are mapped to String (and CKAsset, if needed) on CloudKit side, so I don't see any problem.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

CoreDate->SwiftData Migration & CloudKit
 
 
Q