iPhone | Core data migration for a new version built from scratch

后端 未结 3 1675
遥遥无期
遥遥无期 2021-01-16 09:26

I am working on an App update and this version is completely built from scratch and has completely new coreData model schema. I need to write coreData

相关标签:
3条回答
  • 2021-01-16 10:03

    You can do migration by reading old database with pure sqlite SELECTs and inserting data into new database through coredata model. I've made this in my software to import data from concurrent software :)

    0 讨论(0)
  • 2021-01-16 10:13

    Without the old model schema, you cannot do a migration. Well, that's sort of logical.

    You only perceivable option is to reverse engineer the old model schema and take it from there.

    Then you construct your new schema by adding / deleting / changing entities, attributes and relationships.

    If you can extract the data from the existing store, just write a custom export function and insert it into your brand new core data store.

    0 讨论(0)
  • 2021-01-16 10:15

    If you have the old App, then you can recreate the model from the compiled model file which is contained in the App bundle:

    • Sync the App to iTunes, if necessary.
    • Ctrl-Click on the App in iTunes, and use "Show in Finder" to locate the "YourApp.ipa" file.
    • Copy "YourApp.ipa" to a temporary directory, and use "unzip YourApp.ipa" on the command line to extract the archive.
    • In the extracted "Payload/YourApp.app" folder there should be a "XXX.momd" folder containing a file "XXX.mom" (XXX is the name of the model). This is the compiled model file.
    • In your Xcode project (or a temporary project), create a new "Data Model" file "XXX.xcdatamodeld".
    • Select this file and choose "Editor -> Import ..." from the menu.
    • In the import dialog, choose the "XXX.mom" file from above.
    0 讨论(0)
提交回复
热议问题