Can SwiftData @Model with .externalStorage be used with CloudKit?

Hi,

I'm about to adopt .externalStorage but I will also use CloudKit in the near future. I did not find any reference that list of requirements for SwiftData models to be used with CloudKit, only for Core Data models.

It seems those Core Data requirements (like no-unique) apply to SwiftData as well. However I did not find any info on this:

Can @Attribute(.externalStorage) be used when I want to sync my model with CloudKit?

This is generally true. However you can enable CloudKit temporarily to run the validator against your model. If the ModelContainer initializes the model is compatible (in its current state). If the container throws an error you'll need to make changes.

It's probably worth developing that habit going forward ask a check against introducing invalid changes.

With respect to the .externalStorage parameter, yes you can use it with CloudKit and it will do the right thing. I use that feature in my Stinkbug PM app and it works great.

Can SwiftData @Model with .externalStorage be used with CloudKit?
 
 
Q