Do not try and manually create a Core Data SQLite file. That is a road to failure; every time.
If you have a pre-existing SQLite file then use straight SQLite tools to access it and import it into Core Data using Core Data. Once you have the data in a Core Data stack, save out that file and then use the resulting SQLite file.
The internal structure of the Core Data SQLite file is designed to be opaque and should not be reverse engineered. Apple makes no guarantee that the file structure will stay the same. They have changed it several times already since Core Data was released.
Import
To do the import, it would be just like any other file:
- You stand up the core data stack.
- You walk through each table and each row in the non-Core Data database.
- Create a new Core Data object for each row.
- Insert the data from the old row into the new object.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…