Remove entity from NSPersistentCloudKitContainer
11:57 09 Jan 2026

I'm using NSPersistentCloudKitContainer and I have added an entity (to the private database) to the core data model. Now I have realised that I don't need that entity anymore and I want to get rid of it from my code.

But it doesn't seem to be as simple as deleting it from the core data model and all referencing code. According to this video from WWDC 2022 (https://developer.apple.com/videos/play/wwdc2022/10120/) you can only add new entities and new attributes to entities. No other operations are allowed.

How do people generally deal with this case when using NSPersistentCloudKitContainer ? I tried deleting the entity from core data model and I got some warnings in the log saying that it couldn't find the entity anymore (understandable) and that persistent history tracking dropped for those transactions. Next time I ran the app again I got no warnings. So to me it seemed fine but I asked ChatGPT and did not recommend me to delete it:

Concrete scenarios

Scenario 1: Another device (even months later)

  • User installs app on a new device

  • CloudKit sends all record types it knows

  • Including Entity

  • Core Data can’t map them

  • Sync errors, dropped records, or stalled mirroring

Scenario 2: Old app version comes back

  • User opens an older build from TestFlight / App Store cache

  • That version still creates Entity

  • Uploads records to CloudKit

  • New version can’t decode them

Scenario 3: Background sync edge cases

  • CloudKit delivers changes out-of-order

  • Deletes arrive after inserts

  • Core Data sees a record type it no longer understands

  • Mirroring delegate errors appear later, not immediately

These failures often show up:

  • Days or weeks later

  • On a different device

  • Only for some users

  • As “random CloudKit issues”

Which is why Apple is so strict in WWDC.

ios swift core-data cloudkit nspersistentcloudkitcontainer