I am developing a pod that uses CoreData with a versioned data model. In my latest change, I created a new version (4) from my previous version (3). The only changes I did were adding a new entity and adding a new relation in an existing entity with my newly added entity. These are supported operations for Lightweight Migration according to Apple's documentation (https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/vmLightweightMigration.html).
When I update the pod in a project that uses it and run the app, even though I have set the NSInferMappingModelAutomaticallyOption
and NSMigratePersistentStoresAutomaticallyOption
options to YES
, I get the error
"Can't find model for source store"
In the error log, it says that the NSStoreModelVersionHashesVersion
is 3. Should it be 4? I can't tell... And the NSPersistentStoreCoordinator
's current model hashes seem to be at the correct version (4).
In the documentation, it says :
To perform automatic lightweight migration, Core Data needs to be able to find the source and destination managed object models itself at runtime. Core Data looks for models in the bundles returned by NSBundle’s allBundles and allFrameworks methods. If you store your models elsewhere, you must follow the steps described in Use a Migration Manager if Models Cannot Be Found Automatically .
I have not touched to the bundles (I don't even know what they represent) nor changed the URL of my store. My store URL is
[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
And I add @"mystore.sqlite"
at the end. Why is my migration failing?
Note: If you wonder how I created my new data model version, I did exactly what is listed in this answer : https://stackoverflow.com/a/8363763/1084822