I have an old iOS4.2 app that I want to rebuild in Swift for iOS9. The old app used CoreData and I did not want to recreate the datamodel but simply copy it over. The main reason is that I want users of the old app to be able to preserve their data in the new app.
Wel, it turns out "simply copying" it over did not work.
There are some reports on the net that cover this topic for older versions of Xcode still using Obj-c, but none of those worked for me.
Here is what I ended up doing:
1) In Xcode create the new project
2) Exit Xcode (just to be sure)
3) In the finder go to the <name>.xcdatamodeld and right-click "Show Package Contents"
4) You should see a file <name>.xcdatamodel. Open this in a text editor that will not add formatting. (I used TextWrangler)
5) Select all and Copy
6) Go to the new project and do the same: "Show Package Contents" of <name>.xcdatamodeld, open up <name>.xcdatamodel
7) Select all and Paste (i.e. change the content of the new xcdatamodel file such that it is a copy of the old one)
8) Save the new xcdatamodel file
9) Start up Xcode again, open the new project and you should see the old data model.
Happy coding...
Did this help?, then please help out a small independent.
If you decide that you want to make a small donation, you can do so by clicking this
link: a cup of coffee ($2) or use the popup on the right hand side for different amounts.
Payments will be processed by PayPal, receiver will be sales at balancingrock dot nl
Bitcoins will be gladly accepted at: 1GacSREBxPy1yskLMc9de2nofNv2SNdwqH
We don't get the world we wish for... we get the world we pay for.
No comments:
Post a Comment