Loading CoreData model fails in simulator

Not finding much to match this error message from Google, I am posting this:

I had cause to generate a new version of a CoreData model (xcdatamodel -> xcdatamodeld) and although I was able to happy rely on the automatic model migration when on device, it repeatedly crashed on simulator. The message was:

2010-08-27 16:44:12.566 WildObsLookout[47240:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Bad model.  For entity 'WildObsSearchHistory' superentity 'Account' does not think I am a subentity'

Crazy thing was … I didn’t have any such entity, all mine were prefixed with WildObs.

Turns out this code (not sure where I grabbed it from) was being over zealous on simulator:

NSMutableSet *allBundles = [[[NSMutableSet alloc] init] autorelease];
[allBundles addObjectsFromArray: [NSBundle allBundles]];
[allBundles addObjectsFromArray: [NSBundle allFrameworks]];
managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:[allBundles allObjects]] retain];

The fix was to only load the models I wanted and hand merge them:

NSString *modelPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"WildObs.momd"];
NSManagedObjectModel *model = [[NSManagedObjectModel alloc] initWithContentsOfURL:[NSURL fileURLWithPath:modelPath]];

There is no doubt a better way to load only my *.mom files w/o picking each one individually, but I’ll look for that when I get to version #3. I hope this helps somebody.

Tagged with:
Posted in Programming


As a school administrator with countless observations to conduct daily, Field Notes provides a highly effective vehicle for recording and scripting everything  that is happening in the classroom.  I can easily track the time the teacher or students are conducting a activity, posing questions and monitor time on task.  Teachers love to see the scribed notes and it helps them to be reflective on their teaching, hence improving practices.  The quick keys set up eliminates the need for me to typ…

Help us bring you new apps/features sooner…

See how to become a Neukadye Beta Tester.

Neukadye Newsletter

Low frequency updates on Neukadye's mobile applications.