tutorial-core-data

Core Data Tutorial – How to load SQLITE DB to your IOS device

Posted on 1 Apr ’13

One of the main things that I struggled with and searched a lot of forums for solutions was how to load my SQLITE db from my computer to my IOS device to take testing to the next level.

If you followed the many good tutorials available (I used the one on  Ray Wenderlich’s site), then you have been able to create an SQLITE db, and also be able to test it successfully on the XCODE iPhone simulator.

Testing on the iPhone simulator in XCODE only gets you so far, and you should be ready to test on an actual IOS device, including all of the provisioning stuff such as certificates, provisioning devices etc. (this Techotopia tutorial gives you a detailed run down of all this stuff.)

To load your SQLITE db onto your IOS device, all you need to do is check this setting:

  • Open XCODE.
  • In the Navigator, click on your overall project (top left blue XCODE icon and your project name).
  • Under “Targets” select your project. This should bring up the various settings needed for your target build.
  • Several tabs appear – select “Build Phases”, and from there expand the link called “Copy Bundle Resources”. These are all the resources that will be copied over to the simulator or the IOS device.
  • Can you see your SQLITE db in this list?
  • If yes, then the file will be copied to your IOS device when you run the application for the first time.
  • If not, then hit the “+” sign at the bottom of the “Copy Bundle Resources” window (not the overall “+ Add Target” one!!).
  • XCODE will give you a list of files you can choose from, so select your files and hit “Add”. You can do this for any files for that matter e.g. graphics, sound effects, music files etc. You can also remove files you don’t want to be bundled with your application from here.
  • Now I generally tend to do a “Clean” (under Product –> Clean), select either the simulator or my IOS device (which has already been setup and plugged in), and “Run” (under Product –> Run). This will rebuild your application and also copy all of your resources.

If you done this and you are still hitting problems, check out Stack Overflow, under the IOS and Core Data categories. I’ve had nearly all of my issues answered using this site.

Hope that saves you some time.


Follow

Get every new post delivered to your Inbox

Join other followers