Split Core Data Entity to different stores — Part 2

Topic 3: Manually configure double stores in Core Data and sync with CloudKit (public/private database)

We first check what Xcode done automatically?

  • If your Core Data schema changed, you need to run initializeCloudKitSchema()
let container : NSPersistentCloudKitContainer = getContainer()try container.initializeCloudKitSchema()
  • It takes some time to sync from Core Data to iCloud. So if you are writing unit test, make thread sleep for seconds at the end of the unit test.
Thread.sleep(forTimeInterval: 3)
  • On the CloudKit Portal, you need to add some extra Indexes for every Record Type which Core Data is going to sync with. Otherwise, you will get error like this,

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store