Store is incompatible under iOS 9 ?

Description

I have two persistentStores added to the Coordinator. One has a database (database2.sqlite) located in bundle wich is readonly and the other one (database1.sqlite) is located in the documents which is writeable. A while ago I updated the model and added a new model version. Under iOS 8 this setup works fine, no complaints but under iOS 9 I do not get any objects from the readonly database. Even deleting the app doesn't help. So everyone who is downloading the app from the store are not getting the content stored in the database2.sqlite 😟



Error

CoreData: error: -addPersistentStoreWithType:SQLite configuration:myConfguration2 URL:file:///Users/dev/Library/Developer/CoreSimulator/Devices/0A318522-3097-419D-9E72-337B536762C7/data/Containers/Bundle/Application/8DD5C2B3-E082-496A-B887-39E4B20C1F16/Diabetes360.app/database2.sqlite options:{

NSReadOnlyPersistentStoreOption = 1;

} ... returned error Error Domain=NSCocoaErrorDomain Code=134100 "(null)" UserInfo={metadata={

NSPersistenceFrameworkVersion = 519;

NSStoreModelVersionHashes = {

Basalinsulin = <f9838cfd 18a67029 afb97b73 76bc1737 7ab83e5f 7b1bc3e0 8533355f dbf6a2da>;

Bolusinsulin = <d0e275ce f4144dbf 033a9def 7364b025 be62d48a c29ef624 4168e912 153295a5>;

EigeneLebensmittel = <1520be04 fb0654b2 d0b9aef7 a162c3cd 0b878193 a3f45533 8306cd27 83102ef6>;

Einstellungen = <9b3b15f0 dfb302de 8c0d7561 c657856e 03fded8e 13bf9271 57d62a76 d77d988c>;

Klinik = <819e8bc6 3555debd d229283a 1e9377b7 c55c995f 2e043cde d0b6af0a e0ce477e>;

Lebensmittel = <1ccbebfe 624188cf a6cc6a6d a1f7d282 a87c7c94 d6987704 462ec74e df386575>;

Lebensmittelgruppe = <1eb6c53f b68499a2 b055cccf 36575b5f 11ac432d 385063b7 d714773c bb30c322>;

Medikamente = <f71f835e c21e7d8a 32f904fe 1d072f7c b551ae92 0d596b82 ae189cdf 55411c1f>;

Mischinsulin = <faad2645 6657ae9b 71f146d5 21c891a1 a0baf2cf dc74d3ba ee48a789 f1a7ff31>;

PassJahr = <ce492e18 49c7e8be ac21fff3 30993971 e513d7f2 7e131fb7 7c63d3b1 e9f5457a>;

PassQuartal = <d52c64e8 d1864676 6b1fd4e1 892df045 19c5321d 7b8fca9e 2dd3ab2e c3848365>;

Schaetzung = <a3cf79a4 f861b5ea f477ebc4 24cf4634 eb379bbe 8e1b9f37 bfb249b0 257e9a66>;

Sport = <a0fe73ab bb217b89 826afa2f b9c50249 1bd84aad 601f76b7 32ac4552 9790b6b2>;

TagebuchEintrag = <a1f288ac f70cad64 466c6634 fe81203d f885987f 0283997a 3f931553 440285c1>;

Therapieform = <81edeec2 3e7f7b19 7c53864b 1d43d2d9 5bc20e4a 993b18dd c940a1ad 94598e24>;

};

NSStoreModelVersionHashesVersion = 3;

NSStoreModelVersionIdentifiers = (

""

);

NSStoreType = SQLite;

NSStoreUUID = "CBF73FAB-DF3E-433C-A67C-44F2413E11E2";

"_NSAutoVacuumLevel" = 2;

}, reason=The model used to open the store is incompatible with the one used to create the store} with userInfo dictionary {

metadata = {

NSPersistenceFrameworkVersion = 519;

NSStoreModelVersionHashes = {

Basalinsulin = <f9838cfd 18a67029 afb97b73 76bc1737 7ab83e5f 7b1bc3e0 8533355f dbf6a2da>;

Bolusinsulin = <d0e275ce f4144dbf 033a9def 7364b025 be62d48a c29ef624 4168e912 153295a5>;

EigeneLebensmittel = <1520be04 fb0654b2 d0b9aef7 a162c3cd 0b878193 a3f45533 8306cd27 83102ef6>;

Einstellungen = <9b3b15f0 dfb302de 8c0d7561 c657856e 03fded8e 13bf9271 57d62a76 d77d988c>;

Klinik = <819e8bc6 3555debd d229283a 1e9377b7 c55c995f 2e043cde d0b6af0a e0ce477e>;

Lebensmittel = <1ccbebfe 624188cf a6cc6a6d a1f7d282 a87c7c94 d6987704 462ec74e df386575>;

Lebensmittelgruppe = <1eb6c53f b68499a2 b055cccf 36575b5f 11ac432d 385063b7 d714773c bb30c322>;

Medikamente = <f71f835e c21e7d8a 32f904fe 1d072f7c b551ae92 0d596b82 ae189cdf 55411c1f>;

Mischinsulin = <faad2645 6657ae9b 71f146d5 21c891a1 a0baf2cf dc74d3ba ee48a789 f1a7ff31>;

PassJahr = <ce492e18 49c7e8be ac21fff3 30993971 e513d7f2 7e131fb7 7c63d3b1 e9f5457a>;

PassQuartal = <d52c64e8 d1864676 6b1fd4e1 892df045 19c5321d 7b8fca9e 2dd3ab2e c3848365>;

Schaetzung = <a3cf79a4 f861b5ea f477ebc4 24cf4634 eb379bbe 8e1b9f37 bfb249b0 257e9a66>;

Sport = <a0fe73ab bb217b89 826afa2f b9c50249 1bd84aad 601f76b7 32ac4552 9790b6b2>;

TagebuchEintrag = <a1f288ac f70cad64 466c6634 fe81203d f885987f 0283997a 3f931553 440285c1>;

Therapieform = <81edeec2 3e7f7b19 7c53864b 1d43d2d9 5bc20e4a 993b18dd c940a1ad 94598e24>;

};

NSStoreModelVersionHashesVersion = 3;

NSStoreModelVersionIdentifiers = (

""

);

NSStoreType = SQLite;

NSStoreUUID = "CBF73FAB-DF3E-433C-A67C-44F2413E11E2";

"_NSAutoVacuumLevel" = 2;

};

reason = "The model used to open the store is incompatible with the one used to create the store";

}


Code

NSURL *storeDocumentUrl = [NSURL fileURLWithPath:[DOCUMENT_PATH stringByAppendingPathComponent:@"database1.sqlite"]];

NSError *error;
_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:_managedObjectModel];

NSDictionary *options = @{NSMigratePersistentStoresAutomaticallyOption : [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption : [NSNumber numberWithBool:YES]};
[_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:@"myConfiguration1" URL:storeDocumentUrl options:options error:&error];
   
NSString *path = [[NSBundle mainBundle] pathForResource:@"database2" ofType:@"sqlite"];
NSURL *storeUrl = [NSURL fileURLWithPath:path];
   
NSDictionary *optionsDatabase = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:NSReadOnlyPersistentStoreOption];
[_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:@"myConfiguration2" URL:storeUrl options:optionsDatabase error:&error];
Store is incompatible under iOS 9 ?
 
 
Q