4

Xcode 4 apparently now stores Core Data files in XML, whereas prior versions created binary files. I'd like to convert some older .xcdatamodel files (well, the elements and layout binary files in that package) to XML versions so that I can diff and merge them across multiple source control branches.

Does anyone know how to take an existing Xcode Core Data model file (.xcdatamodeld, .xcdatamodel, or whatever) and convert it to the newer XML file?

Noah Harrison
  • 197
  • 1
  • 5
  • 15
  • I've posted this to the Core Data Apple developer forum as well, but so far no responses: https://devforums.apple.com/message/671357 – Noah Harrison Jun 21 '12 at 03:06

3 Answers3

5

You can convert the old binary files to XML by changing the Tools Version on the .xcdatamodel file in Xcode.

Steps:

  1. Select the .xcdatamodel file in Xcode.
  2. In the Utilities pane (⌘⌥0 - the pane on the right side), find Core Data Model > Tools Version and set the Minimum to Xcode 4.1 (or greater).
  3. Voila! Your .xcdatamodel file should now be formatted as XML.

Core Data Model > Tools Version

Thanks to Sam Hatchett's answer for pointing me to this answer which ultimately led to the solution.

Community
  • 1
  • 1
Josh Brown
  • 52,385
  • 10
  • 54
  • 80
1

I don't have a binary xcdatamodel file to try this out, but would the answer to this question do what you need? Basically to import the old file as a "version" of the new data model?

Community
  • 1
  • 1
Sam Hatchett
  • 513
  • 5
  • 11
  • I'm not sure how you'd import the old file as a version of the new one. I created a new model file, then tried various dragging techniques to get the old file into the new one - nothing seems to work. – Josh Brown Sep 06 '12 at 14:49
  • Just found the Editor menu > Import... which does not allow me to import the old binary file. In fact, I don't have any idea what that's for. Perhaps that function could be used somehow if there were some documentation about it... – Josh Brown Sep 06 '12 at 15:06
  • I wonder if [this answer might help](http://stackoverflow.com/a/8899089/787801) - looks like you can adjust the versions of xcdatamodel(d) file you can open... but i may be misunderstanding that interface. – Sam Hatchett Sep 06 '12 at 16:18
0

I think the only way I know is to write a tool that catches all informations from old format and generates a "skeleton" of new format and fill in thus values. Can we get an example of old and new format?

  • The old format is binary and the new format is XML. I'm not interested in writing a converter - I'm looking for an existing tool from Apple... – Josh Brown Sep 06 '12 at 15:33