Reputation: 5841
I'm trying to migrate my core data data to a new version. The only change I've done is adding one field (NSString *sessionId)
So what I've done: 1. Create version 2 of my core data file 2. Add sessionId in this file. 3. set version 2 as default. 4. add sessionId in Offer.m and .h 5. When initializing the persistentStoreCoordinator adding the options:
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
When Im starting my application when i thought it would get the updated model i get:
Unresolved error Error Domain=NSCocoaErrorDomain Code=134130 "The operation couldn’t be completed. (Cocoa error 134130.)" UserInfo=0x7643200 {URL=/Users/ei/Library/Application Support/iPhone Simulator/4.0.2/Applications/81B816AE-5CA0-46DB-83E7-6A765EBF9D05/Documents/Offers.sqlite, metadata={type = immutable dict, count = 7,
Followed by
reason=Can't find model for source store
I get the same error if I don't set the options when loading the persistentStoreCoordinator What is it I am missing?
Upvotes: 0
Views: 1079
Reputation: 5841
Apparently, if you merge two models and then try to automatically migrate from one model to another doesnt work. We ended up separating them.
Upvotes: 1
Reputation: 33592
The error message means exactly what it says: it's missing the .xcdatamodel (or strictly .mom) that the database was saved with. I'd try grabbing the .xcdatamodel from an old revision and seeing if there have been accidental changes.
Another problem is that Xcode isn't good at deleting files which are no longer being built, both when building and when installing (Xcode is allowed to do "incremental installs" to make development quicker, and at least in previous versions, never deleted files). Instead of building MyApp.app/MyModel.mom, it's now building MyApp.app/MyModel.momd/MyModel.mom, but the old MyModel.mom might stick around and confuse whatever you're using to load the model (usually it complains about being unable to merge models, though...). The fix is to nuke the build directory and install the app using OTA/iPhone Configuration Utility/iTunes (in order of user-friendliness), and is incidentally why I tell Xcode 4 to stick build products in the project dir (the reason why they changed it is presumably because people aren't smart enough to not commit it...).
Upvotes: 0