How to import contacts into the iPhone Simulator

    November 9th, 2011 Posted by: - posted under:Tutorials

    If you’re working with AddressBook.framework chances are you’ll want to import your own data to test against when you’re in the simulator. Without being able to sync with iTunes or iCloud you may think you’re stuck entering in addresses manually; not only is that a huge pain, but there are probably lots of edge cases already in your address book you wouldn’t necessarily think of.

    Fortunately there’s another option, with a tool called . Download it, run it and click Read Backups (note that you’ll need to back up to iTunes, not iCloud). Select your device, and you should see a list of apps included in your backup. Choose the last item on the list, iOS Files, and extract it to your desktop. When it’s done take a look in the folder it created. You should find two files in the folder iOS Files/Library/AddressBook, AddressBook.sqlitedb and AddressBookImages.sqlitedb.

    Next, open the simulator’s Application Support folder (in the Finder menu, choose Go -> Go to Folder…, enter ~/Library/Application Support/iPhone Simulator, and choose the SDK you’re working with) and drill down to Library/AddressBook. Quit the simulator if it’s open, delete everything in this directory, then copy the two files noted above from your backup. That’s it! If everything went well the next time you launch the simulator you should see all your contacts.

    Pretty easy, really. If address book data is a major feature of your app, you might even want to have a few trusted beta testers send you their backups so you can test with their contacts. My experience is that there are a lot of unusual or invalid contacts floating around on people’s phones, and the more opportunity you have to test the better you’ll do once you release your app.