问题
Basically, I have a Versioned xcdatamodel
and I am migrating from V2 to V3
I created a Mapping Model
with a custom policy.
Once the PersistenStoreCoordinator
tries to do its job, I hit a Cocoa Error No. 134140 (can't find mapping model for migration)
This Question basically is the same one I'm having but I am using Xcode 4.6.3
Things I have tried:
- Forcing the
xcmappingmodel
to reside inside thexcdatamodelId
and ensuring my mapping model is not 0kb in size as per the answer of this question - Removing the
xcdatamodelId
references from Xcode and adding them back (answer of this question) - Clean and Clean Build Folder options
EDIT Here are my debug statements if anyone is interested...
Handling DB Upgrade
sourceMetadata is {
NSPersistenceFrameworkVersion = 419;
NSStoreModelVersionHashes = {
OriginalPicture = <ce8de6ad c694b569 dcc1d706 d4df3928 05052cab 14a092f1 340cbf01 2306e861>;
PanoramicInfo = <923298fa 0af16c01 d5ba91ca 19c6252c 8adee68a bfe7b86b 75285500 6883a1aa>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "F83640F3-8686-438F-97CC-48311EB74B9C";
"_NSAutoVacuumLevel" = 2;
}
Not Compatible Models Migration is NEEDED!
SourceEntity: OriginalPicture: <ce8de6ad c694b569 dcc1d706 d4df3928 05052cab 14a092f1 340cbf01 2306e861>
DestinationEntity: OriginalPicture: <ce8de6ad c694b569 dcc1d706 d4df3928 05052cab 14a092f1 340cbf01 2306e861>
SourceEntity: PanoramicInfo: <923298fa 0af16c01 d5ba91ca 19c6252c 8adee68a bfe7b86b 75285500 6883a1aa>
DestinationEntity: PanoramicInfo: <1d7836cd f3ccf5fa 487c1984 e2b3f46c abc3b706 c06512d5 0bac698c a5d8cb20>
The operation couldn’t be completed. (Cocoa error 134140.)
Second EDIT
I've been trying to get the Mapping Model directly by using:
NSURL *fileURL = [[NSBundle mainBundle] URLForResource:@"Update23Model" withExtension:@"cdm"];
But strangely fileURL points to nil.....
How do you add the mapping model to the bundle then?
回答1:
Looks like an Xcode 4.6.3 bug...
The xcmappingmodel
must not be inside any group folder it seems....
When I created it at the root level of the xcode project, the mapping was found by the IDE.
回答2:
Would this answer fix your problem ? The problem seems similar, sorry if it doesn't help.
回答3:
This can happen if your test device's store is from a version of the data model that no longer exists.
For example I had Data Model Version 7, then I made Data Model Version 8. I made a mapping model to go from 7 to 8. Then I made some more changes to 8. When I open that app, it will give this error because the version of 8 that the mapping model was based on, no longer exists.
来源:https://stackoverflow.com/questions/18150816/mapping-model-nowhere-to-be-found-cocoa-error-134140