XCode - Copy sqlite DB from simulator and copy onto device for testing
I am working on a Core Data app, and have populated the sqlite file in the iPhone Simulator with all of the fixtures/data that I use to test the app. 开发者_运维问答I would like to use that sqlite file as a standardized set of testing data.
The devices that I test the app on all have different data sets, and I would like to standardize on the one in the simulator.
Is there a way in XCode (3 or 4) to add a step to the build/install process that will copy the sqlite file from the iPhone Simulator and install it over the file on the phone (if one exists)?
Thanks, Neal
If you locate the sqllite file in question, likely in ~/Library/Application Support/iPhone Simulator/{version}/Applications/{application id}/
, you can copy it to your project and add it to the build process. You'll want to copy it, for when you reset the sim.
On a couple of projects, I've added a unit test to determine if the 'default' sqllite database exists (I link it from the test build directory). Then, if the database is missing, I have the unit test create it (either using a text-file: csv or sql). Taking this approach has allowed me to later alter the schema, data, etc. It also allows me to run tests against the default database.
精彩评论