Exclude some SwiftData Models from CloudKit sync

Hi,

I'd like to prevent some model classes from CloudKit sync. They are not referenced from - aka have no relation to - the synced model objects. Is there an straightforward way to do this?

Answered by DTS Engineer in 800369022

You can achieve that by creating two model containers, one being configured with a CloudKit database (.automatic or .private) and the other with .none. That way, you turn out have two stores: the one with a CloudKit database will sync with CloudKit, and the other won't.

There is no way today to exclude some models from CloudKit synchronization in one single SwiftData + CloudKit store.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

You can achieve that by creating two model containers, one being configured with a CloudKit database (.automatic or .private) and the other with .none. That way, you turn out have two stores: the one with a CloudKit database will sync with CloudKit, and the other won't.

There is no way today to exclude some models from CloudKit synchronization in one single SwiftData + CloudKit store.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Exclude some SwiftData Models from CloudKit sync
 
 
Q