Is there any way to add a sqlite database originally created with iCloud enabled to a NSPersistentStoreCoordinator if the iCloud option is not passed in to the "addPersistentStore" call?
I know the data is in the file but I cannot figure out how to get at it without first loading the persistent store with iCloud enabled. The problem with doing this is that the iCloud implementation in the app I am working on is totally botched and I would prefer to avoid using iCloud at all (in fact I'm not sure it's even an option). In iOS6 you used to be able to access the store this way on a "read-only" basis but in fairness it did warn that this would become a fatal error in the future. In the future (iOS7) it does not work, just warns that I cannot access the container without the same options used to create it (i.e. iCloud). In fact in my case the app appears to create a whole new store and completely ignores the fact that there is a sqlite file I pointed it to. Instead it creates a new store in the "CoreDataUbiquitySupport" folder.
My sqlite file is in the "Documents" directory (and not in a .nosync folder). All I want to do is access this file as though it was not an iCloud store.
Any thoughts?
I was able to do this by using a modified version of the "solution 2" part of the answer to this question: How can I migrate the data from the iCloud store file to a new store file in local storage?
The difference being that instead of adding the iCloudStore to the PersistentStoreCoordinator I am instead using the getMetadata and setMetadata methods of NSPersistentStore which allow me to manipulate the metadata (and strip out the ubiquity keys) without having to add the persistent store first.