views:

145

answers:

0

Hi All, I'm developing an iPhone Core Data app with a pre-populated sqlite database. In parallel with developing the app in Xcode, we continue to add new data to our sqlite database and so every few days we update the new sqlite database in the project.

This is done by adding the sqlite file as a resource in the Xcode project, deleting the previous sqlite database from the application documents directory (e.g. for the iPhone simulator this would be Library/Application Support/iPhone Simulator/User/Applications//documents) and having the Core Data persistentStoreCoordinator copy over the new resource sqlite database if the file doesn't exist in the application documents directory.

All of the above works fine when a new database is added to the project. The problem is every few days, Xcode seems to revert the sqlite database to a previous version. To repeat:

Week 1: the Xcode project has sqlite db containing data ver 1.0. All ok.
Week 2: add sqlite db containing data ver 1.1 to Xcode project. All ok.
Week 3: No database update. Run my app and Xcode randomly reverts sqlite db to data ver 1.0.

To resolve this I simply overwrite sqlite data ver 1.0 by copy/pasting my ver 1.1 database file into the application documents directory so I don't lose any time with this problem. But it bugs me that this is happening. Is this a symptom of a deeper problem which may manifest itself on the iPhone device (where I've never seen this problem). Or is this just one of those things, maybe XCode environment / persistent store coordinator just got itself in a twist and ended up copying a much older application documents directory into the new application documents directory (as I understand with every app launch, iPhone Simulator creates a fresh application documents directory).

Appreciate insight/pointers anyone can provide. Thanks for reading and apologies on verbosity.