How to get application data from the iPhone

Andy on Aug 14th 2008

If you’ve written any kind of non-trivial application from the iPhone, you’ve had to deal with debugging it while not in the debugger. Sometimes you may even need to get at the preferences file and other support files, such as “saved state” files to see what went wrong.

There are two main ways to go about retrieving application data for your iPhone applications, depending on whose phone you want to get it off of. If it’s your personal phone you do development on, it’s pretty easy. If you need to get data from someone else, like say a beta user, it’s much more involved.

For your iPhone

If you’re on your development machine and iPhone, Xcode provides a pretty simple way to get at the data.

  1. First, dock your iPhone, then open Xcode.

  2. In Xcode, open the Organizer, via the Window > Organizer menu item.

  3. Select your iPhone in the source list on the left.

    OrganizerSourceList.png

  4. On the right, locate the Applications list. Find your application, and disclose the disclosure triangle to the left of the name.

    OrganizerApplications.png

  5. Select “Application Data” underneath the name of your application, and press the button on the right, the down arrow image.

  6. You will be prompted for a place to save it. Pick a place, and press “Save.”

You now have your application data onto your Mac, where you can debug it. You can either go to the Finder to browser it, or it is also added to the Organizer window in Xcode, under the “Projects & Sources” tree.

For a beta tester’s iPhone

If you are running a beta and you need to get data from your application to debug, things get pretty tricky. The general idea is you get your beta user to find the iTunes backup files (yes, more than one) that contain your application data, and have them send them to you. Then, using a third party python script, you uncompress the backup files, and hope that they actually contain the correct files.

  1. First, if the user does not yet have a backup (unlikely), they should force one. Do this by selecting the iPhone in iTunes, right clicking (or control-click) and selecting “Backup”.

    iTunesBackup.png

  2. Next, the beta user should open the Finder and go to ~/Library/Application Support/MobileSync/Backup. With any luck, there will be one folder here, which will be the 40 character hexadecimal device ID of their iPhone. Navigate inside this folder.

  3. In the Finder, switch to list view and sort by modification date.

    iTunesBackupFiles.png

  4. At this point, your beta user needs to select the appropriate backup files that contain the data you need (haha). Depending on your user, you may want them to just zip up the entire folder and send it to you. Be warned though — it’s huge.

    To be more selective, you only want the files ending in “mdbackup.” These files can be grouped based on modification date. For example, in the screenshot above, you can see that a backup happened Today, at 5:06 PM. The beta user could select all of the mdbackup files with a modification date of “Today, 5:06 PM”, zip them up, and email them to you.

    The thing to note here is that iTunes only does incremental backups. If your application data has not been modified since the previous backup, the current backup will not have your data in it. So you may need to repeat this step several times with your beta user until they find the right backup.

  5. At this point the beta user should zip up the “mdbackup” files, however you had them select them, and email them to you.

Things are now in your, the developer’s, hands. You need to convert the mdbackup files into something you can use.

  1. First, download iphone-backup-decoder from Google Code. iphone-backup-decode is a Python script that will unarchive all those mdbackup files you now have.

  2. Next, make a directory that you can work in, called “Backups” (or whatever you want to call it). Place all your mdbackup files in here, and move decode_iphone_backup_v2.1.py file here as well.

  3. Before you can run the python script, you need to make it executable. In Terminal.app, cd to your “Backups” folder, and type the following:

    chmod a+rx decode_iphone_backup_v2.1.py

  4. You are now ready to run the decoder, by typing in Terminal:

    ./decode_iphone_backup_v2.1.py *.mdbackup

    This will unarchive all mdbackup files current in the “Backup” folder, so keep that in mind if you’re going through multiple backups.

The results should now be in a folder called “MobileSyncExport” inside your “Backups” folder. If you are very lucky, it will contain the files you need.

If you need to repeat these steps, I would advise deleting all the mdbackup files and the MobileSyncExport folder from your Backups folder. The decoder script will most likely give undesirable results if you decode two backups that contain the same file.

Filed in Programming, iPhone | 2 responses so far

Twitter Induced Silence

Andy on Mar 4th 2008

I just realized I hadn’t posted to my blog in a few months. The lack of content has been caused both me just being busy, and me being on Twitter.

If you would like to follow me, I’m macgeek02. I’ll update my contact page to contain my handle as well.

I still definitely have plans for more graphics articles, it will just take me a while to write and post them.

Filed in Personal, Writing | No responses yet

I support Stepwise

Andy on Dec 21st 2007

It has come to my attention that Scott Anguish has made the decision to pull Stepwise offline. You can read all the details at Stepwise, but the basic gist of it is, someone took some of Scott’s articles, republished them without permission, and misrepresented Scott’s feelings about the direction of Mac OS X.

Although I’m not a lawyer and can’t offer any legal advice or support, I can do something. First, I can express my displeasure at someone who claims to be part of the Mac developer community treating Stepwise, or any other developer for that matter, in this manner. I can ask Rixstep to remove the copyrighted material. Finally, I can inform the audience of this blog about what’s going on.

Scott, via Stepwise, has been instrumental in my journey with Mac OS X programming. When I was first getting acquainted with Cocoa in the OS X Beta days, I often found myself over at Stepwise, checking out the tutorials. When I began writing tutorials on this blog, Scott would link to some of them. I often used Stepwise as a barometer as to how relevant my posts were.

I hope that Rixstep will relent, and remove the offending material. It would be best for the Mac developer community if Stepwise came back.

Filed in Macintosh, Personal, Programming | 2 responses so far

Married man

Andy on Oct 28th 2007

It feels very strange to have a ring on my finger, since I don’t normally wear any jewelry at all, including a watch. But I think it suits me well.

The ceremony went quite well (it went quicker than we thought it would, no flubs or people passing out), and Elaine was absolutely stunning.

A couple of the more humorous moments:

  • One of my groomsmen: “Leopard goes on sale on Friday… is the wedding rehearsal still on?”, “I could be experiencing 300 new features right now…”, etc
  • My best man’s tux pants being about 8 inches too short, leading to many Futurama references, especially Zap’s “Have the boy lay out my formal shorts.”

Well, those are a few of the more geeky ones.

Thanks to all who came and/or sent gifts, especially from Texas and Tennessee. If I can’t visit home, it’s nice when it comes to visit me.

And now, on to Tahiti. I’ll be thinking of you when I’m lying on a beach in the south Pacific. Honest.

Filed in Personal | 2 responses so far

And now a brief intermission

Andy on Oct 25th 2007

I’m calling a time out so I can go get married.

I was hoping to post another graphics article before the big day, but I’ve come to the conclusion that that’s simply not going to happen. I know what I want to write about next, and have quite a bit of code going in that direction, but it’s not quite ready yet. It’ll happen, just a lot later than I planned.

Finding time is further complicated by the fact that after the wedding, we have our honeymoon, then we visit my side of the family for about a week (since they’re on the other side of the country, and most can’t make it to the actual wedding). The end result is that I’m not going to be home for almost a month. Makes it hard to write up articles.

Anyway, I haven’t abandoned the blog, and more graphics articles are coming, it’ll just be a while.

Filed in Personal | 3 responses so far

Bad Behavior has blocked 702 access attempts in the last 7 days.