0

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

Community
  • 1
  • 1
Raphael Royer-Rivard
  • 2,252
  • 1
  • 30
  • 53
  • 1
    One thing I would try is, instead of adding new entity, add a new attribute as a test and see if it migrates. Then you can narrow down what's causing the fail. – SFF May 29 '15 at 22:24
  • 1
    Have you checked to see that the old version of the model is actually present in the app bundle? – Tom Harrington May 29 '15 at 23:11
  • 1
    Are you sure that version 3 of the model didn't accidentally get modified also? – Eric Hedstrom May 30 '15 at 19:43
  • When I tried to test what you suggest, I downloaded the last version of my app from the AppStore and I retried the lightweight migration. This time it worked, so I guess what happened is that I installed a modified version of the app on my iPhone that had modifications to the model version 3 but I reverted them later. – Raphael Royer-Rivard Jun 01 '15 at 13:51

0 Answers0