EMart
EMart

Reputation: 73

Update iCloud Scheme through NSPersistentCloudKitContainer to newest Core Data Version

I'm stuck in finding a proper solution for migrating the CloudKit scheme to my newest local Core Data Model. The CloudKit model won't update even when pushing new changes. I tried to update the scheme manually but it appears to be faulting and quite time consuming. Any suggestions?

Upvotes: 1

Views: 350

Answers (2)

Viktor Gavrilov
Viktor Gavrilov

Reputation: 976

In my case the problem was with a type of one Record:

  • in CloudKit it was initially synced as Double

  • than I've decided to change it's type to String

For a such type of errors you get a Core Data warning, but it is not so easy to spot it due to a number of such messages in console.

So I've removed this Record in iCloud dashboard (you could delete records only if they were not moved to Production) and after that my new scheme (with new Records and Relationships) was updated in a moment with a standard command:

let options = NSPersistentCloudKitContainerSchemaInitializationOptions()
try? container.initializeCloudKitSchema(options: options)

Upvotes: 0

danmedia
danmedia

Reputation: 51

Have you tried one of the following after loading the persistent store?

try? container.initializeCloudKitSchema(options: .printSchema)

or

try? container.initializeCloudKitSchema(options: .dryRun)

And what exactly have you changed? If you're still in development, you could reset the environment in CloudKit Dashboard.

Upvotes: 1

Related Questions