Search code examples
iosxcodecore-data-migration

Mapping Model nowhere to be found (Cocoa Error 134140)


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 the xcdatamodelId 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?


Solution

  • 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.