SwiftData - Cloudkit stopped syncing

I have an app that from day 1 has used Swiftdata and successfully sync'd across devices with Cloudkit. I have added models to the data in the past and deployed the schema and it continued to sync across devices. Sometime I think in June.2025 I added a new model and built out the UI to display and manage it. I pushed a version to Test Flight (twice over a matter of 2 versions and a couple of weeks) and created objects in the new model in Test Flight versions of the app which should push the info to Cloudkit to update the schema.

When I go to deploy the schema though there are no changes. I confirmed in the app that Cloudkit is selected and it's point to the correct container. And when I look in Cloudkit the new model isn't listed as an indes.

I've pushed deploy schema changes anyway (more than once) and now the app isn't sync-ing across devices at all (even the pre-existing models aren't sync-ing across devices).

I even submitted the first updated version to the app store and it was approved and released. I created objects in the new model in production which I know doesn't create the indexes in the development environment. But this new model functions literally everywhere except Cloudkit and I don't know what else to do to trigger an update.

Answered by DTS Engineer in 856406022

You mentioned that "the new model isn't listed as an indes". Does that mean your new model type does not show up as part of the CloudKit schema (and hence CloudKit Console sees "no changes" between your development and production schemas )? If yes, that will be the culprit – The framework will stop synchronizing data when detecting that the CloudKit schema doesn't match your SwiftData models.

When changing your SwiftData model types, be sure that the change is pushed to the CloudKit development environment, which is eventually promoted to the production environment. How to push your change to the CloudKit development environment is described in Initialize the CloudKit development schema. The details in Create the CloudKit schema may help as well.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

You mentioned that "the new model isn't listed as an indes". Does that mean your new model type does not show up as part of the CloudKit schema (and hence CloudKit Console sees "no changes" between your development and production schemas )? If yes, that will be the culprit – The framework will stop synchronizing data when detecting that the CloudKit schema doesn't match your SwiftData models.

When changing your SwiftData model types, be sure that the change is pushed to the CloudKit development environment, which is eventually promoted to the production environment. How to push your change to the CloudKit development environment is described in Initialize the CloudKit development schema. The details in Create the CloudKit schema may help as well.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

I know that the culprit is that the model isn't in the CloudKit schema. I also know that the fix is to push the model to the development environment which is why I described the steps I'd take to do just that. As I said in the beginning, I've had this model in CloudKit since its inception. And I've added other models previously.

From day 1 I've never had to do anything with NSPersistentStoreDescription or Request Core Data load the store synchronously, to guarantee that the load finishes before you attempt to initialize the CloudKit schema.

I did do any of that when I first created the data models or when I added models or anything.

I've always just opened the app in Test Flight and then the new models were in CloudKit development and then I could deploy the schema changes.

So, you're telling me....that method doesn't work any longer? And now I have to write a segment of code I've never had to write before in order to get the new model into CloudKit?

I mean, I guess thank you for the links but that seems unusual that a method that's worked for multiple apps over the past year or so just...doesn't work any more?

In CloudKit development environment, when your app creates a record, CloudKit automatically creates the record type, if it doesn’t exist. With that, if you ever persist (at least) an instance for each of your SwiftData type, and the instance is pushed to CloudKit, the CloudKit schema will have the record type for you. Otherwise, the record type will be missed.

initializeCloudKitSchema(options:) works by creating a set of representative records, uploading them to CloudKit, and removing them. This may help if it is indeed that no instance of your new SwiftData type has ever been uploaded to CloudKit.

Note that even initializeCloudKitSchema(options:) can miss something, and that is why I called out the following:

" After running the target, use CloudKit Console to ensure each Core Data entity and attribute has a CloudKit counterpart. See Reading CloudKit Records for Core Data for the mapping rules. "

The documentation discusses how NSPersistentCloudKitContainer maps a Core Data model to a CloudKit schema, which doesn't directly help in your case if you don't know how SwiftData maps a model type to a Core Data entity. In that case, you can probably figure that out by observing what CloudKit Console creates for you when you add a new SwiftData model instance.

Eventually, the solution for your case is that you make sure the CloudKit schema is right. If the system doesn't do that correctly for you, you can consider doing it manually.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

SwiftData - Cloudkit stopped syncing
 
 
Q