I plan on synching CoreData objects in my app with a web service like Parse. So the objects will exist on the server, BUT I also want to ship them with the app, so that they are already there when the user installs it. I don’t want to rely on an internet connection to download everything upon install. I only want to do updates to the objects through the web service. So how do I get these objects into my app bundle to start with?
Share
Add a second “prepopulation” target to your app. Set this target up so that all it does is download/sync the content from the server and load it into the database (i.e. make sure you disable any prompts for user details, or anything that would insert user-generated content into the database).
Run the “prepopulation” target using the iOS simulator. Note where your app’s files are being stored (simplest way to do this is with an
NSLogstatement in the app).When the “prepopulation” run completes, find the app’s database file in your filesystem and copy it into your project. Make sure your non-prepopulation target is set up to install this prebuilt database before it tries to sync any content from the server (just copy the database file into place the first time the app runs).
Profit!