Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrating a Core Data Store from iCloud to local

I'm currently struggling with Core Data iCloud migration.

I want to move a store from an iCloud ubiquity container (.nosync) to a local URL. The problem is that whenever I call something like this:

[self.persistentStoreCoordinator migratePersistentStore: currentiCloudStore 
                                                  toURL: localURL 
                                                options: nil 
                                               withType: NSSQLiteStoreType 
                                                  error: &error];

I get this error:

-[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:](1055): CoreData: Ubiquity:  Error: A persistent store which has been previously added to a coordinator using the iCloud integration options must always be added to the coordinator with the options present in the options dictionary. If you wish to use the store without iCloud, migrate the data from the iCloud store file to a new store file in local storage. file://localhost/Users/sch/Library/Containers/bla/Data/Documents/tmp.sqlite. This will be a fatal error in a future release

Anyone ever seen this? Maybe I'm just missing the right migration options?

like image 689
schmok Avatar asked Oct 05 '12 21:10

schmok


People also ask

Should I use core data with CloudKit?

Use Core Data with CloudKit to give users seamless access to the data in your app across all their devices. Core Data with CloudKit combines the benefits of local persistence with cloud backup and distribution. Core Data provides powerful object graph management features for developing an app with structured data.

Where is CloudKit data stored?

You use CloudKit to store your app's existing data in the cloud so that the user can access it on multiple devices. You can also store data in a public area where all users can access it.

Is CloudKit free?

Cost. Although the running cost of servers is a big deal for developers. But in case of CloudKit you don't have to be worried about paying large expenses at all. As it offers a reasonable storage amount completely free.


1 Answers

My guess is that, based on the error message, by setting your options to nil, the PSC is unable to move the store. You probably need to get the dictionary of options for the original store and pass those along instead of setting them to nil.

like image 61
Mike Avatar answered Oct 21 '22 12:10

Mike