问题
I am facing weird IOS app issue for the Core Data migration. Below are the mentioned Logs for your This issue only happens when an IOS8 Device migrates app from lower version to newer version.Note I am already passing this test in IOS9 using the model version light data migration upgrade.
Any quick help is much appreciated as its in production.
CoreData: error: -addPersistentStoreWithType:SQLite configuration:(null) URL:file:///xxxxx/Documents/Application.sqlite options:{
NSInferMappingModelAutomaticallyOption = 1;
NSMigratePersistentStoresAutomaticallyOption = 1;
} ... returned error Error Domain=NSCocoaErrorDomain Code=134130 "The operation couldn’t be completed. (Cocoa error 134130.)" UserInfo=0x171a7ca80 {URL=file:///xxxxx/Documents/Application.sqlite, metadata={
NSPersistenceFrameworkVersion = 519;
NSStoreModelVersionHashes = {
ChatTAble = <a131aa9a f7588fa9 598a8949 05511a36 d0bf9ea9 33c0a87e 96828261 f5de30d4>;
OperationTable = <6a3eaabc 7ef604c6 deb9314a 309bf207 378ff20a 4be5546a 6b602826 f0d049db>;
Contact = <db1bb713 c747ff41 d73a018c a5208828 8dcd87e8 d4d8afd8 c37f055b 3d7f7f5a>;
Email = <35cfbcd3 d990c32c 2bd3b793 a55a6e06 5f88a3a8 d67f77e7 d4a63c17 a512cf73>;
Table3 = <373be7dc e2ab077d f0503f49 6a9f8b78 0b5392d9 c5fc2309 e4035d2b 6fd49388>;
Table4 = <42c77ddb da95c75b 22186c01 5407888f 41c92961 47ec4d22 e8183b35 3d002893>;
RCTable1 = <c9dc1b34 b49b1c2b 291f32a6 f5297396 21152a09 c12cd735 15caf6bb e5aade3b>;
TAble2 = <cd2d5199 058890f8 0dd7381f dfae070b ffab95e8 8ca28838 cb6f6127 7bde6f3c>;
User = <88f315d2 6b34a4f4 4ce1b4ed ee2cf303 94c9a7bc 3efe7d71 7e84744b 1203d13a>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "CDAB1111-D8D9-4021-B8B5-C8B823FBFD3F";
"_NSAutoVacuumLevel" = 2;
}, reason=Can't find model for source store} with userInfo dictionary {
URL = "file:///xxxx/Documents/Application.sqlite";
metadata = {
NSPersistenceFrameworkVersion = 519;
NSStoreModelVersionHashes = {
ChatTAble = <a131aa9a f7588fa9 598a8949 05511a36 d0bf9ea9 33c0a87e 96828261 f5de30d4>;
OperationTable = <6a3eaabc 7ef604c6 deb9314a 309bf207 378ff20a 4be5546a 6b602826 f0d049db>;
Contact = <db1bb713 c747ff41 d73a018c a5208828 8dcd87e8 d4d8afd8 c37f055b 3d7f7f5a>;
Email = <35cfbcd3 d990c32c 2bd3b793 a55a6e06 5f88a3a8 d67f77e7 d4a63c17 a512cf73>;
Table3 = <373be7dc e2ab077d f0503f49 6a9f8b78 0b5392d9 c5fc2309 e4035d2b 6fd49388>;
Table4 = <42c77ddb da95c75b 22186c01 5407888f 41c92961 47ec4d22 e8183b35 3d002893>;
RCTable1 = <c9dc1b34 b49b1c2b 291f32a6 f5297396 21152a09 c12cd735 15caf6bb e5aade3b>;
TAble2 = <cd2d5199 058890f8 0dd7381f dfae070b ffab95e8 8ca28838 cb6f6127 7bde6f3c>;
User = <88f315d2 6b34a4f4 4ce1b4ed ee2cf303 94c9a7bc 3efe7d71 7e84744b 1203d13a>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "CDAB1111-D8D9-4021-B8B5-C8B823FBFD3F";
"_NSAutoVacuumLevel" = 2;
};
reason = "Can't find model for source store";
}
2015-12-30 13:55:11.279 Closrr_LV4[8639:2062615] CoreData: annotation: NSPersistentStoreCoordinator's current model hashes are {
ChatTAble = <53f22878 98260327 12c33f30 8d3ef551 a1d7f284 079eb744 212a896f e13d6398>;
OperationTable = <92a573a7 a131a638 754226be 515cd608 84d6f04a f58b8e28 6e477951 4d2a143d>;
ChatPushConfig = <d0ecca3f 05d67a77 7a909f4f f9bae449 f6338c17 1a70991f 11cabaf3 efbb15d6>;
Contact = <1d6da19b 5bb3ca73 480e4235 9aedb38d 4dbd80d1 402f0f00 715504b4 4a165454>;
Table3 = <072e4c37 22cc6fcd d77c8e66 235df69a f8478d4e 9e76894c e0bffbf6 448bf321>;
GMTable = <5cd15514 954477e9 439521cc c48044de 6e15c3f7 dfb6289e 260f8c26 4182cf78>;
Table4 = <a949a462 e11e300c 1be32e1f 9106c5e5 a2d16ce1 93b8ed68 8c9fe18f fff9886e>;
RCTable1 = <f526cbca 492a30ab 9af60b86 fd7d103f e9bfed46 1aa3daad ae9ea90f 37cb3cc6>;
TAble2 = <3e371807 557217db 22e78097 0055a51c bcec2200 4a1ced2e 79c8e612 63220389>;
User = <dbe32c0d 95fc9df5 bf457c67 906be0c5 f659e106 d52497ac eb3da3f3 b1e1fcbc>;
}
回答1:
On iOS versions 8 and under, you need to explicitly create new versions of your schema in your project, such that iOS can compare the two schemas from the app bundle and perform the lightweight migration.
in iOS 9, the Core Data store stores the current schema alongside the (sqlite) datafile(s), such that if/when you change the schema in the app bundle, it can perform the lightweight migration between the schema captured on disk and the new schema in your app bundle.
here's a quick google search result to point you in the right directions… http://www.informit.com/articles/article.aspx?p=2150667&seqNum=2
回答2:
To avoid the crash I created new database for iOS 8 because I didnt need existing data that much.
I changed my storeURL from
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"Project.sqlite"];
to
NSURL *storeURL;
if (OS_VERSION<9.0)
{
storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"Project1.sqlite"];
}
else
{
storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"Project.sqlite"];
}
This fixed the crash for me.
来源:https://stackoverflow.com/questions/34523929/core-data-migration-issue-in-ios-8-only-not-ios-9