Iphone debugging tutorial

If you have ever experienced a bug in your application that took many steps to reproduce, then this tutorial is for you. By nature, testing and debugging are very tedious processes. This is especially the case for the iPhone.

Say you have an app that drills down 5-levels deep to some other view. Now let’s say that you have a bug on that view 5 levels deep. Your normal method of debugging is:

* Run the app
* Tap view 1
* Tap view 2
* Tap view 3
* Tap view 4
* Tap view 5
* (Crash)
* Change some code
* Repeat

As you can see (and I’m sure have noticed), this sucks. Well, Kendall Gelner gave a killer talk at 360iDev (which I recently attended) on various debugging tips using Instruments and XCode. One of the most useful techniques (to me) was how to automate your testing. Let me show you what I mean.

1. Open up the app you wish to test/debug

2. Launch it in the simulator

3. Open Instruments – This is located in /Developer/Applications/Instruments (just do a spotlight search for it)



4. Select UIRecorder and click Choose - You should now see a window like this


5. Now, we need to attach this tool to the iPhone Simulator process. Click the drop-down above Default Target -> Attach to Process -> iPhone Simulator.


6. Now click Drive & Record and do all of the steps in the simulator to test your app. At this point, the UI Recorder is recording your every move. When you have finished press the Stop button. Note: After you have recorded your actions, don’t move the simulator as it will mess up the entire process.

7. Modify your code…

8. Press the Drive & Record button and watch the magic happen. The test is automatically done for you. You should see your mouse move over to the simulator and the system mimicking every action that you did before.

That’s it! I know this isn’t a super long tutorial (or even a coding tutorial)

No comments: