Search code examples
ioscore-datacore-data-migration

iOS CoreData MappingModel


I am unclear on how to use the Xcode interface to add additional mapping models. Currently I have a Versioned DB and used core data simple migration to go from V1 to V2. But now that I need to go from V2 to V3 in some cases and V1 to V3 depending on where the user is in his app update cycle.

My specific problem is that when I use Xcode to create the additional Mapping models, it puts them in separate files. But the only one that CoreData detects automatically is the one named "Model.xcmappingmodel". Should ALL the mappings be IN this file and if so how do you get them in there using Xcode4?

I was under the impression that CoreData looked at the users version of the db and then what the "current" version of the db should be and looked for mapping models to use to migrate? If it does, it is NOT finding the other mapping models?


Solution

  • Each mapping goes into its own file. The behavior you're seeing - that some of the mapping models are not found at runtime - is probably a bug. I've had similar symptoms, as reported here (were resolved by a "clean all"). You can look inside the app bundle to see which of your mapping models "made it".

    So your impressions are correct, but the Xcode implementation of the specs isn't bug free :-(