Skip to main content


In most cases you just need to create a CloudKitSynchronizer instance using the convenience initializer for the model technology that your app uses. In a Core Data app you would do:

let synchronizer =   CloudKitSynchronizer.privateSynchronizer(containerName: "your-iCloud-container",                                            managedObjectContext: self.managedObjectContext)

And in a Realm app you would use:

let synchronizer =   CloudKitSynchronizer.privateSynchronizer(containerName: "your-iCloud-container",                                            configuration: self.realmConfiguration)

Internally, SyncKit will configure a model adapter for your model to track any changes that need to be sent to iCloud. Then you would simply call synchronize to trigger a CloudKit sync.

synchronizer.synchronize { error in

And that's it. Some further configuration might be needed for your technology, so do check the Core Data and Realm sections.

Your model#

SyncKit observes your data model and keeps track of local changes so they can be uploaded using CloudKit when you trigger a synchronization. Conversely, when you synchronize data SyncKit will fetch new records from CloudKit and apply those changes to your local model.

Because your data will be uploaded in the form of multiple CKRecord, your properties should be of any type that conforms to CKRecordValueProtocol, that is, for attribute fields they can be of any of these types: Array, Bool, CLLocation, Data, Date, Double, Float, Int, Int16, Int32, Int64, Int8, NSArray, NSData, NSDate, NSNumber, NSString, String, UInt, UInt16, UInt32, UInt64, UInt8

Relationship fields should be an instance of another object in your model.

Note that Data fields are uploaded as CKAsset by default, unless you explicitly force them to be uploaded as Data using the forceDataTypeInsteadOfAsset option.

If you want to use some other property type, it might be possible to do so by using custom record processing

If using Core Data, your property can also be defined as Transformable, and SyncKit will use your ValueTransformer to upload it as Data. However, although this works for now, it is recommended that you adopt custom record processing and add your own code to convert the property to a CKRecordValueProtocol. SyncKit might drop out-of-the-box support for transformable properties in the future.