所以,我搞砸了。我在Xcode中创建了一个现有CoreData模型的新版本,并以某种方式从未提交.xcdatamodel
文件(或更准确地说,提交了contents
文件)。现在,不久之后,该文件已经丢失,我无法恢复它。试图在xcode中打开xcdatamodel文件给我错误“文件”内容“因为没有这样的文件而无法打开”。
我认为我可以聪明并从先前版本的contents
文件中复制.xcdatamodel
文件,然后只需添加我为此迁移添加的表(幸运的是我只添加了一个表并生成一个类,因此再次创建表很容易)。问题是,当我在模拟器或已存在数据的设备上运行应用程序时,出现以下错误:Error Domain=NSCocoaErrorDomain Code=134130 "The operation couldn’t be completed. (Cocoa error 134130.)"
该错误还列出了NSPersistentStoreCoordinator的当前模型哈希,所以现在我假设所讨论的模型的哈希很可能是不同的。
我有什么选择?如何修复数据,以便用户在更新之前不必卸载应用程序并丢失所有数据?
以下是错误的完整内容:
2015-01-21 11:01:11.050 Marq[2699:607] CoreData: annotation: Incompatible version schema for persistent store 'file:///Users/aerion/Library/Developer/CoreSimulator/Devices/71815540-57DE-49BF-A6F6-69500A54281F/data/Applications/EE5B15A6-A5ED-46EB-9DFD-B6B54353E35B/Documents/ARUPInspect_Schema.sqlite'. store metadata = {
NSPersistenceFrameworkVersion = 479;
NSStoreModelVersionHashes = {
Asset = <4b2b421f 4295c02f 89b5a2e8 1c4fc3e9 2b515eca 95e89ad6 e65c891d f82b1090>;
BooleanValue = <3e1758f6 0f04f670 5c150cd4 55f0a0eb b5c1a17e 8b1abdcc ab7044ba fd02dd5e>;
Client = <c52499f9 a0f482f7 9bdcb115 8217e157 1861f63a e926b55c e7cc85bb b4044464>;
DataValue = <43afe89a 90c53a31 4b839b5f b914896b 8ad165de dd46a159 6aac5f86 2d75058c>;
DataValueCollection = <78dce1b0 9f20a1a9 15004f99 65d71d00 46e7c949 80d599ea 622b2574 be9245a4>;
DateValue = <54571596 1267b4f2 5f14ee12 a0be1b3f 53d79056 7d612f33 e827b90e 7c4c847b>;
DirectoryItem = <b716a315 e40d91b6 18bb918e ab448086 48bc62b2 5a26e959 2c4a0cb4 8fc8d319>;
DirectoryNode = <c718b896 a2a90890 596409a2 c50240aa 1e5e347c f9d9c4df 1a5567fe 8bca7ed3>;
DoubleValue = <b63cba59 de2b200e 199c5ec4 ce17494a a8df75be bac353c0 3c5d9af7 fbf36240>;
Group = <0e912576 760d5fd4 df8a5bbe 13b7922d 6760a046 ea6fee68 3fcd4bd4 c9de7b3b>;
Inspection = <e7fc6688 bee2906d 8f8b7f5e 4f69d1da 59bdbb17 0a620529 c0abc426 d164a44f>;
InspectionMetaData = <982fe134 141245a4 97ca1cde aaa04843 90746c85 80ddedcc ed63b9a4 b3d40477>;
IntegerValue = <97fbd40d a463d4ed 282aa03b 4b5892fe 7fcac137 b4cc590b 03d79bb9 cfee4517>;
Observation = <651371ad be372494 10e31b83 509db973 6021af3b 79895e59 f38e0a9f 0b35a63e>;
ObservationGroup = <92f680bb b4b5243c 83b665e6 35e0d569 634aa24f 455de69e c8c3b666 84c6a858>;
Project = <97879f96 cdc99c88 6e6a614f aa81519b 2ba1f415 e4424a57 66d3f32e 3700829f>;
ProjectPreferredTemplate = <35381035 33dac226 aaeee194 fcd8ad4c e5c5506f a2c597ce 24ba7256 6f34f084>;
SchemaDataRepresentation = <c1843de9 2192b6f8 8f68d807 d5b0d2ac ab276b3c 67c48dc4 f363d92d 89ce1019>;
StringValue = <a7948007 c3454244 7cea0dcd c85b69b5 db5501fb 35e2a242 31907b97 558f1fb0>;
TemplateMetaData = <8f0702e9 8bbb5d4f 71c6a455 2a344af6 e967b2bb abcf05d3 96cd9ffc 328fe362>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "4512A0DB-E887-4294-9E75-840B9861ECA8";
"_NSAutoVacuumLevel" = 2;
} and current model versions = {
Asset = <4b2b421f 4295c02f 89b5a2e8 1c4fc3e9 2b515eca 95e89ad6 e65c891d f82b1090>;
BooleanValue = <3e1758f6 0f04f670 5c150cd4 55f0a0eb b5c1a17e 8b1abdcc ab7044ba fd02dd5e>;
Client = <c52499f9 a0f482f7 9bdcb115 8217e157 1861f63a e926b55c e7cc85bb b4044464>;
DataValue = <43afe89a 90c53a31 4b839b5f b914896b 8ad165de dd46a159 6aac5f86 2d75058c>;
DataValueCollection = <cb0da8d0 a2c307de 53600c9c 214dfeab bcefc9f0 0507f6e6 1b8ef683 ef608349>;
DateValue = <54571596 1267b4f2 5f14ee12 a0be1b3f 53d79056 7d612f33 e827b90e 7c4c847b>;
DirectoryItem = <b716a315 e40d91b6 18bb918e ab448086 48bc62b2 5a26e959 2c4a0cb4 8fc8d319>;
DirectoryNode = <b9da47a0 bdaf3956 5e75039f e3429a42 bf34d642 871c2f6d 7da7edfa f5380634>;
DoubleValue = <b63cba59 de2b200e 199c5ec4 ce17494a a8df75be bac353c0 3c5d9af7 fbf36240>;
Group = <0e912576 760d5fd4 df8a5bbe 13b7922d 6760a046 ea6fee68 3fcd4bd4 c9de7b3b>;
Inspection = <e7fc6688 bee2906d 8f8b7f5e 4f69d1da 59bdbb17 0a620529 c0abc426 d164a44f>;
InspectionMetaData = <982fe134 141245a4 97ca1cde aaa04843 90746c85 80ddedcc ed63b9a4 b3d40477>;
IntegerValue = <97fbd40d a463d4ed 282aa03b 4b5892fe 7fcac137 b4cc590b 03d79bb9 cfee4517>;
Observation = <651371ad be372494 10e31b83 509db973 6021af3b 79895e59 f38e0a9f 0b35a63e>;
ObservationGroup = <92f680bb b4b5243c 83b665e6 35e0d569 634aa24f 455de69e c8c3b666 84c6a858>;
Project = <97879f96 cdc99c88 6e6a614f aa81519b 2ba1f415 e4424a57 66d3f32e 3700829f>;
ProjectPreferredTemplate = <35381035 33dac226 aaeee194 fcd8ad4c e5c5506f a2c597ce 24ba7256 6f34f084>;
SchemaDataRepresentation = <c1843de9 2192b6f8 8f68d807 d5b0d2ac ab276b3c 67c48dc4 f363d92d 89ce1019>;
StringValue = <a7948007 c3454244 7cea0dcd c85b69b5 db5501fb 35e2a242 31907b97 558f1fb0>;
TemplateMetaData = <8f0702e9 8bbb5d4f 71c6a455 2a344af6 e967b2bb abcf05d3 96cd9ffc 328fe362>;
}
2015-01-21 11:01:11.055 Marq[2699:607] CoreData: annotation: (migration) will attempt automatic schema migration
2015-01-21 11:01:11.335 Marq[2699:607] CoreData: error: (migration) migration failed with error Error Domain=NSCocoaErrorDomain Code=134130 "The operation couldn’t be completed. (Cocoa error 134130.)" UserInfo=0x6b58f220 {URL=file:///Users/aerion/Library/Developer/CoreSimulator/Devices/71815540-57DE-49BF-A6F6-69500A54281F/data/Applications/EE5B15A6-A5ED-46EB-9DFD-B6B54353E35B/Documents/ARUPInspect_Schema.sqlite, metadata={
NSPersistenceFrameworkVersion = 479;
NSStoreModelVersionHashes = {
Asset = <4b2b421f 4295c02f 89b5a2e8 1c4fc3e9 2b515eca 95e89ad6 e65c891d f82b1090>;
BooleanValue = <3e1758f6 0f04f670 5c150cd4 55f0a0eb b5c1a17e 8b1abdcc ab7044ba fd02dd5e>;
Client = <c52499f9 a0f482f7 9bdcb115 8217e157 1861f63a e926b55c e7cc85bb b4044464>;
DataValue = <43afe89a 90c53a31 4b839b5f b914896b 8ad165de dd46a159 6aac5f86 2d75058c>;
DataValueCollection = <78dce1b0 9f20a1a9 15004f99 65d71d00 46e7c949 80d599ea 622b2574 be9245a4>;
DateValue = <54571596 1267b4f2 5f14ee12 a0be1b3f 53d79056 7d612f33 e827b90e 7c4c847b>;
DirectoryItem = <b716a315 e40d91b6 18bb918e ab448086 48bc62b2 5a26e959 2c4a0cb4 8fc8d319>;
DirectoryNode = <c718b896 a2a90890 596409a2 c50240aa 1e5e347c f9d9c4df 1a5567fe 8bca7ed3>;
DoubleValue = <b63cba59 de2b200e 199c5ec4 ce17494a a8df75be bac353c0 3c5d9af7 fbf36240>;
Group = <0e912576 760d5fd4 df8a5bbe 13b7922d 6760a046 ea6fee68 3fcd4bd4 c9de7b3b>;
Inspection = <e7fc6688 bee2906d 8f8b7f5e 4f69d1da 59bdbb17 0a620529 c0abc426 d164a44f>;
InspectionMetaData = <982fe134 141245a4 97ca1cde aaa04843 90746c85 80ddedcc ed63b9a4 b3d40477>;
IntegerValue = <97fbd40d a463d4ed 282aa03b 4b5892fe 7fcac137 b4cc590b 03d79bb9 cfee4517>;
Observation = <651371ad be372494 10e31b83 509db973 6021af3b 79895e59 f38e0a9f 0b35a63e>;
ObservationGroup = <92f680bb b4b5243c 83b665e6 35e0d569 634aa24f 455de69e c8c3b666 84c6a858>;
Project = <97879f96 cdc99c88 6e6a614f aa81519b 2ba1f415 e4424a57 66d3f32e 3700829f>;
ProjectPreferredTemplate = <35381035 33dac226 aaeee194 fcd8ad4c e5c5506f a2c597ce 24ba7256 6f34f084>;
SchemaDataRepresentation = <c1843de9 2192b6f8 8f68d807 d5b0d2ac ab276b3c 67c48dc4 f363d92d 89ce1019>;
StringValue = <a7948007 c3454244 7cea0dcd c85b69b5 db5501fb 35e2a242 31907b97 558f1fb0>;
TemplateMetaData = <8f0702e9 8bbb5d4f 71c6a455 2a344af6 e967b2bb abcf05d3 96cd9ffc 328fe362>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "4512A0DB-E887-4294-9E75-840B9861ECA8";
"_NSAutoVacuumLevel" = 2;
}, reason=Can't find model for source store}
Error User Info: {
URL = "file:///Users/aerion/Library/Developer/CoreSimulator/Devices/71815540-57DE-49BF-A6F6-69500A54281F/data/Applications/EE5B15A6-A5ED-46EB-9DFD-B6B54353E35B/Documents/ARUPInspect_Schema.sqlite";
metadata = {
NSPersistenceFrameworkVersion = 479;
NSStoreModelVersionHashes = {
Asset = <4b2b421f 4295c02f 89b5a2e8 1c4fc3e9 2b515eca 95e89ad6 e65c891d f82b1090>;
BooleanValue = <3e1758f6 0f04f670 5c150cd4 55f0a0eb b5c1a17e 8b1abdcc ab7044ba fd02dd5e>;
Client = <c52499f9 a0f482f7 9bdcb115 8217e157 1861f63a e926b55c e7cc85bb b4044464>;
DataValue = <43afe89a 90c53a31 4b839b5f b914896b 8ad165de dd46a159 6aac5f86 2d75058c>;
DataValueCollection = <78dce1b0 9f20a1a9 15004f99 65d71d00 46e7c949 80d599ea 622b2574 be9245a4>;
DateValue = <54571596 1267b4f2 5f14ee12 a0be1b3f 53d79056 7d612f33 e827b90e 7c4c847b>;
DirectoryItem = <b716a315 e40d91b6 18bb918e ab448086 48bc62b2 5a26e959 2c4a0cb4 8fc8d319>;
DirectoryNode = <c718b896 a2a90890 596409a2 c50240aa 1e5e347c f9d9c4df 1a5567fe 8bca7ed3>;
DoubleValue = <b63cba59 de2b200e 199c5ec4 ce17494a a8df75be bac353c0 3c5d9af7 fbf36240>;
Group = <0e912576 760d5fd4 df8a5bbe 13b7922d 6760a046 ea6fee68 3fcd4bd4 c9de7b3b>;
Inspection = <e7fc6688 bee2906d 8f8b7f5e 4f69d1da 59bdbb17 0a620529 c0abc426 d164a44f>;
InspectionMetaData = <982fe134 141245a4 97ca1cde aaa04843 90746c85 80ddedcc ed63b9a4 b3d40477>;
IntegerValue = <97fbd40d a463d4ed 282aa03b 4b5892fe 7fcac137 b4cc590b 03d79bb9 cfee4517>;
Observation = <651371ad be372494 10e31b83 509db973 6021af3b 79895e59 f38e0a9f 0b35a63e>;
ObservationGroup = <92f680bb b4b5243c 83b665e6 35e0d569 634aa24f 455de69e c8c3b666 84c6a858>;
Project = <97879f96 cdc99c88 6e6a614f aa81519b 2ba1f415 e4424a57 66d3f32e 3700829f>;
ProjectPreferredTemplate = <35381035 33dac226 aaeee194 fcd8ad4c e5c5506f a2c597ce 24ba7256 6f34f084>;
SchemaDataRepresentation = <c1843de9 2192b6f8 8f68d807 d5b0d2ac ab276b3c 67c48dc4 f363d92d 89ce1019>;
StringValue = <a7948007 c3454244 7cea0dcd c85b69b5 db5501fb 35e2a242 31907b97 558f1fb0>;
TemplateMetaData = <8f0702e9 8bbb5d4f 71c6a455 2a344af6 e967b2bb abcf05d3 96cd9ffc 328fe362>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "4512A0DB-E887-4294-9E75-840B9861ECA8";
"_NSAutoVacuumLevel" = 2;
};
reason = "Can't find model for source store";
}
2015-01-21 11:01:11.340 Marq[2699:607] -[AISDataService persistentStoreCoordinator] line 1410 $ Unresolved error Error Domain=NSCocoaErrorDomain Code=134130 "The operation couldn’t be completed. (Cocoa error 134130.)" UserInfo=0x6b58f220 {URL=file:///Users/aerion/Library/Developer/CoreSimulator/Devices/71815540-57DE-49BF-A6F6-69500A54281F/data/Applications/EE5B15A6-A5ED-46EB-9DFD-B6B54353E35B/Documents/ARUPInspect_Schema.sqlite, metadata={
NSPersistenceFrameworkVersion = 479;
NSStoreModelVersionHashes = {
Asset = <4b2b421f 4295c02f 89b5a2e8 1c4fc3e9 2b515eca 95e89ad6 e65c891d f82b1090>;
BooleanValue = <3e1758f6 0f04f670 5c150cd4 55f0a0eb b5c1a17e 8b1abdcc ab7044ba fd02dd5e>;
Client = <c52499f9 a0f482f7 9bdcb115 8217e157 1861f63a e926b55c e7cc85bb b4044464>;
DataValue = <43afe89a 90c53a31 4b839b5f b914896b 8ad165de dd46a159 6aac5f86 2d75058c>;
DataValueCollection = <78dce1b0 9f20a1a9 15004f99 65d71d00 46e7c949 80d599ea 622b2574 be9245a4>;
DateValue = <54571596 1267b4f2 5f14ee12 a0be1b3f 53d79056 7d612f33 e827b90e 7c4c847b>;
DirectoryItem = <b716a315 e40d91b6 18bb918e ab448086 48bc62b2 5a26e959 2c4a0cb4 8fc8d319>;
DirectoryNode = <c718b896 a2a90890 596409a2 c50240aa 1e5e347c f9d9c4df 1a5567fe 8bca7ed3>;
DoubleValue = <b63cba59 de2b200e 199c5ec4 ce17494a a8df75be bac353c0 3c5d9af7 fbf36240>;
Group = <0e912576 760d5fd4 df8a5bbe 13b7922d 6760a046 ea6fee68 3fcd4bd4 c9de7b3b>;
Inspection = <e7fc6688 bee2906d 8f8b7f5e 4f69d1da 59bdbb17 0a620529 c0abc426 d164a44f>;
InspectionMetaData = <982fe134 141245a4 97ca1cde aaa04843 90746c85 80ddedcc ed63b9a4 b3d40477>;
IntegerValue = <97fbd40d a463d4ed 282aa03b 4b5892fe 7fcac137 b4cc590b 03d79bb9 cfee4517>;
Observation = <651371ad be372494 10e31b83 509db973 6021af3b 79895e59 f38e0a9f 0b35a63e>;
ObservationGroup = <92f680bb b4b5243c 83b665e6 35e0d569 634aa24f 455de69e c8c3b666 84c6a858>;
Project = <97879f96 cdc99c88 6e6a614f aa81519b 2ba1f415 e4424a57 66d3f32e 3700829f>;
ProjectPreferredTemplate = <35381035 33dac226 aaeee194 fcd8ad4c e5c5506f a2c597ce 24ba7256 6f34f084>;
SchemaDataRepresentation = <c1843de9 2192b6f8 8f68d807 d5b0d2ac ab276b3c 67c48dc4 f363d92d 89ce1019>;
StringValue = <a7948007 c3454244 7cea0dcd c85b69b5 db5501fb 35e2a242 31907b97 558f1fb0>;
TemplateMetaData = <8f0702e9 8bbb5d4f 71c6a455 2a344af6 e967b2bb abcf05d3 96cd9ffc 328fe362>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "4512A0DB-E887-4294-9E75-840B9861ECA8";
"_NSAutoVacuumLevel" = 2;
}, reason=Can't find model for source store}, {
URL = "file:///Users/aerion/Library/Developer/CoreSimulator/Devices/71815540-57DE-49BF-A6F6-69500A54281F/data/Applications/EE5B15A6-A5ED-46EB-9DFD-B6B54353E35B/Documents/ARUPInspect_Schema.sqlite";
metadata = {
NSPersistenceFrameworkVersion = 479;
NSStoreModelVersionHashes = {
Asset = <4b2b421f 4295c02f 89b5a2e8 1c4fc3e9 2b515eca 95e89ad6 e65c891d f82b1090>;
BooleanValue = <3e1758f6 0f04f670 5c150cd4 55f0a0eb b5c1a17e 8b1abdcc ab7044ba fd02dd5e>;
Client = <c52499f9 a0f482f7 9bdcb115 8217e157 1861f63a e926b55c e7cc85bb b4044464>;
DataValue = <43afe89a 90c53a31 4b839b5f b914896b 8ad165de dd46a159 6aac5f86 2d75058c>;
DataValueCollection = <78dce1b0 9f20a1a9 15004f99 65d71d00 46e7c949 80d599ea 622b2574 be9245a4>;
DateValue = <54571596 1267b4f2 5f14ee12 a0be1b3f 53d79056 7d612f33 e827b90e 7c4c847b>;
DirectoryItem = <b716a315 e40d91b6 18bb918e ab448086 48bc62b2 5a26e959 2c4a0cb4 8fc8d319>;
DirectoryNode = <c718b896 a2a90890 596409a2 c50240aa 1e5e347c f9d9c4df 1a5567fe 8bca7ed3>;
DoubleValue = <b63cba59 de2b200e 199c5ec4 ce17494a a8df75be bac353c0 3c5d9af7 fbf36240>;
Group = <0e912576 760d5fd4 df8a5bbe 13b7922d 6760a046 ea6fee68 3fcd4bd4 c9de7b3b>;
Inspection = <e7fc6688 bee2906d 8f8b7f5e 4f69d1da 59bdbb17 0a620529 c0abc426 d164a44f>;
InspectionMetaData = <982fe134 141245a4 97ca1cde aaa04843 90746c85 80ddedcc ed63b9a4 b3d40477>;
IntegerValue = <97fbd40d a463d4ed 282aa03b 4b5892fe 7fcac137 b4cc590b 03d79bb9 cfee4517>;
Observation = <651371ad be372494 10e31b83 509db973 6021af3b 79895e59 f38e0a9f 0b35a63e>;
ObservationGroup = <92f680bb b4b5243c 83b665e6 35e0d569 634aa24f 455de69e c8c3b666 84c6a858>;
Project = <97879f96 cdc99c88 6e6a614f aa81519b 2ba1f415 e4424a57 66d3f32e 3700829f>;
ProjectPreferredTemplate = <35381035 33dac226 aaeee194 fcd8ad4c e5c5506f a2c597ce 24ba7256 6f34f084>;
SchemaDataRepresentation = <c1843de9 2192b6f8 8f68d807 d5b0d2ac ab276b3c 67c48dc4 f363d92d 89ce1019>;
StringValue = <a7948007 c3454244 7cea0dcd c85b69b5 db5501fb 35e2a242 31907b97 558f1fb0>;
TemplateMetaData = <8f0702e9 8bbb5d4f 71c6a455 2a344af6 e967b2bb abcf05d3 96cd9ffc 328fe362>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "4512A0DB-E887-4294-9E75-840B9861ECA8";
"_NSAutoVacuumLevel" = 2;
};
reason = "Can't find model for source store";
}
答案 0 :(得分:5)
您尝试重新创建缺失版本时遇到的错误几乎可以肯定是因为您没有以完全相同的方式重新创建它。如果您完全不确定,最简单的方法就是再试一次。如果您创建的新内容与旧版本的完全匹配,则没有理由不起作用。
如果您不能这样做,可以使用以下方法从应用程序的应用商店副本恢复模型:
如果您从Xcode存档(.xcarchive
)开始,那只是一个包含应用包和其他内容的文件包。浏览它以查找包含所有核心数据模型的momd
,然后查看该软件包以查找与您的缺失版本匹配的单个mom
。将该文件复制到存档之外的某个位置。
如果您从ipa
开始,那只是一个包含该应用的zip文件。使用您喜欢的任何解压缩工具解压缩,然后按上述步骤查找正确的mom
。
mom
文件是已编译的模型,但与源代码不同,模型编译可以反转。在Xcode中创建一个新的模型版本并删除其中的所有内容,以便它完全为空。然后转到编辑器菜单并选择导入... 。导入上面找到的mom
文件。
现在,您应该拥有与应用程序中已编译模型完全对应的Core Data模型版本。 将其提交到您的源代码存储库,以便下次可以使用。
答案 1 :(得分:-1)
您应该能够通过核心数据迁移来解决这个问题:http://www.raywenderlich.com/27657/how-to-perform-a-lightweight-core-data-migration