I have already built an app using SwiftData and now I want to introduce CloudKit features in it, what should I do? I'm totally new to this part. Thank you!
To implement SwiftData + CloudKit, here is what you need to do:
-
Configure CloudKit for your app. This is covered in Configuring iCloud services, and is also discussed in Configure iCloud on your devices and Configure CloudKit in your project.
-
Specify the CloudKit database when creating the model configuration for your model container. If your app uses only one CloudKit container, the default value of the cloudKitDatabase parameter, .automatic, should just work. Otherwise, use .private(_:) to specify the right CloudKit container.
Only CloudKit private database can be integrated with SwiftData as of today, as mentioned here.
Best,
——
Ziqiao Chen
Worldwide Developer Relations.