migratePersistentStore does not work for ubiquitous stores

Originator:poissonnier
Number:rdar://12253540 Date Originated:07-Sep-2012 12:22 PM
Status:Open Resolved:
Product:iCloud Product Version:6.0
Classification: Reproducible:
 
Summary:

I am using NSPersistentStoreCoordinator migratePersistentStore:toURL:options:withType:error to migrate an iCloud store to a local store when the user disables iCloud.
Calling this method logs an error:

2012-09-07 12:13:50.864 App[28271:907] -[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/var/mobile/Applications/67CD10C5-A883-40A4-AD66-DBEE02C06CCC/Documents/CoreDataStores/fallbackStore.sqlite
This will be a fatal error in a future release.
 
I assume this is because migratePersistentStore is using addPersistentStore internally.
After this, the migrated local store can not be saved anymore. save: always fails with:

Error Domain=NSCocoaErrorDomain Code=134030 "The operation couldn’t be completed. (Cocoa error 134030.)"

Migrating from local to iCloud works just fine.
Dropping and loading the local store doesn't change any of this, and the same error is logged when directly calling addPersistentStore on the local store after it has been migrated.

Steps to Reproduce:

call
        self.fallbackStore = [self.persistentStoreCoordinator migratePersistentStore:self.iCloudStore
                                                                               toURL:self.fallbackStoreURL
                                                                             options:options
                                                                            withType:NSSQLiteStoreType
                                                                               error:&localError];


Expected Results:

Store is migrated properly to a local store.

Actual Results:

Local store can be read but not saved.

Regression:

Notes:


15-Sep-2012 02:01 PM Julien Poissonnier:
Added sample project based on the Master-Detail Application Xcode project template. The Core Data store is added with ubiquity options. The master view has a toolbar button "Migrate" which will start the migration.
The migration functionality is implemented in -[JPAppDelegate migrateToLocal].

Performing the migration will output the warning in the log. Saving the context after the migration results in the error in -[NSManagedObjectContext save:].

15-Sep-2012 02:01 PM Julien Poissonnier:
'Migration.zip' was successfully uploaded

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!