Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Core Data Migration - Can't find mapping model for migration

I followed the guide found here: http://www.timisted.net/blog/archive/core-data-migration/ but keep getting "Can't find mapping model for migration" when I start up the app with the new model. I've tried it in xcode 3 and xcode 4, multiple times, but can never get it to work.

Currently my options are set to:

NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
    [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
    [NSNumber numberWithBool:NO], NSInferMappingModelAutomaticallyOption,
    nil];

I had YES set for the infer option before but then it was just migrating without calling my custom policies that I need to migrate, which I assume is cause it couldn't find the mapping model before either.

Any reason my mapping models aren't getting picked up? I've double checked that no changes were made to the previous model by checking it against the SVN version of it.

Thanks.

like image 958
Philippe Sabourin Avatar asked Mar 20 '11 16:03

Philippe Sabourin


2 Answers

Turns out the Mapping Model needs to be part of the .xcdatamodeld package, which is impossible to do within xcode 4. With it in there, it works great.

Note: my mapping file stopped working again, and I found that it was 0KB on disc, so I had to recreate it again and it worked fine after that. I quickly committed it and will see if it disappears again. The problem is that Xcode 4 indexes it or something so it looks fine in xcode but on the file system its empty.

See my comment below for the reason (xcode 4's mapc (map compiler) is broken).

** THIS HAS BEEN FIXED IN THE NEWER XCODEs/SDKs.**

like image 137
Philippe Sabourin Avatar answered Sep 28 '22 19:09

Philippe Sabourin


I had a similar problem:

Custom Policy in my xcmappingmodel will not be executed

in my case it was not executed since my migration did not do any changes to the tables - maybe this is your problem too.

like image 42
sippndipp Avatar answered Sep 28 '22 20:09

sippndipp