SwiftData with shared and private containers

I was hoping for an update of SwiftData which adopted the use of shared and public CloudKit containers, in the same way it does for the private CloudKit container.

So firstly, a big request to any Apple devs reading, for this to be a thing!

Secondly, what would be a sensible way of adding a shared container in CloudKit to an existing app that is already using SwiftData?

Would it be possible to use the new DataStore method to manage CloudKit syncing with a public or shared container?

Answered by DTS Engineer in 790189022

SwiftData + CloudKit public or shared database isn't supported today. If that is critical to your app, I suggest that you file a feedback report to voice your need.

The framework, including the new DataStore API, doesn't provide supports in that regard. You can choose to implement your own way, similar to what NSPersistentCloudKitContainer does, but that will be obviously very involved.

I'd probably stick with NSPersistentCloudKitContainer, if I do need the integration with CloudKit public or shared database.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

SwiftData + CloudKit public or shared database isn't supported today. If that is critical to your app, I suggest that you file a feedback report to voice your need.

The framework, including the new DataStore API, doesn't provide supports in that regard. You can choose to implement your own way, similar to what NSPersistentCloudKitContainer does, but that will be obviously very involved.

I'd probably stick with NSPersistentCloudKitContainer, if I do need the integration with CloudKit public or shared database.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

This is disappointing. I had really hoped this WWDC would bring the announcement that SwiftData now supported collaboration. I had already filed FB requesting this (FB13801092, not that long ago, alas), but honestly I'm surprised Apple wasn't already working on this.

When you introduce new technologies that are meant to replace older ones, you really need to follow up quickly with replacement for all the older functionality.

SwiftData with shared and private containers
 
 
Q