New Core Data model gives error when upgrading

200 Views Asked by At

I am simply wanting to add a BOOL to my core data model, but it keeps crashing my app. I've added a new Model Version from the Editor menu. Added my BOOL then changed the Current Model Version to my new one.

In my App Delegate I added these options:

_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc]
                                   initWithManagedObjectModel:[self managedObjectModel]];
    NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                             [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
                             [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
    if(![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
                                                  configuration:nil URL:storeUrl options:options error:&error]) {
        /*Error for store creation should be handled in here*/
        if (error) {
            NSLog(@"%@", error);
        }
    }

Now when my app loads I get this error:

Error Domain=NSCocoaErrorDomain Code=134130 "The operation couldn’t be completed. (Cocoa error 134130.)" UserInfo=0x17e4d2a0 {URL=file:///var/mobile/Applications/EFB5D875-4872-4874-AF92-038C2140E9E8/Documents/Data.sqlite, metadata={ NSPersistenceFrameworkVersion = 479; NSStoreModelVersionHashes = { Data = <92870bec c4a8794e 293dcbe9 93282d69 cb675039 cb9b9bf6 8dda6359 34697663>; Event = ; Snap = <97a4acac 24668ba4 a763d216 51cb1a97 9d42362f 419be977 9d2deb2e f3cd5f7e>; }; NSStoreModelVersionHashesVersion = 3; NSStoreModelVersionIdentifiers = ( "" ); NSStoreType = SQLite; NSStoreUUID = "C7D445CD-5ED7-4C36-B885-AD430911FA81"; "_NSAutoVacuumLevel" = 2; }, reason=Can't find model for source store}

Doing some reading, it seems that the problem might have something to do with the fact my project has more than 1 .xcdatamodeld file. I use Countly analytics, which comes with it's own xcdatamodeld file. It hasn't been a problem, but I think now is causing upgrade issues.

So how can I fix this to update my own core data model?

0

There are 0 best solutions below