Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

iphone - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.**


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...