Using Swift to Seed Core Data for Testing

Andrew Bancroft on creating test data using Core Data and Swift:

“During development, I’ve found that it’s often convenient to seed a Core Data database with sample data so that I can preview how it’ll look in my application. Along with that, it’s nice to start with a fresh copy of the data each time I run the app.”

Here’s another tip: I often create command line parameters that I pass into an application (using Xcode Scheme “Arguments Passed on Launch”) to specify resetting a database or other files. This gives me control to turn the reset on/off as needed.