Debugging iPhone Apps

This is pretty basic, but I didn’t find this info all in one place, so I figured I’d post it here.

If your iPhone app is crashing, here’s a series of steps you can take to troubleshoot it:

  1. Check your build warnings. Just because there were no errors that prevented execution, doesn’t mean your app won’t crash. One common warning I often have to fix is mistyped method names. Objective-C will compile your code if you call methods on an object that don’t exist, but it will throw an exception at runtime.
  2. Check your Xcode console. Most crashes will show up here.
  3. Check your Mac OS X console. This is found under Applications/Utilities/Console. Sometimes a crash won’t output data in the Xcode console for some reason, but it will output it here.
  4. Check your Diagnostic Reports folder. This is found under /Users/youruser/Library/Logs/DiagnosticReports. When your app crashes in the simulator, it should create a new crash file here. Double-clicking one will open it in the Console app, and it should have info on what line number the crash happened on.
  5. Check your CrashReporter folder. This is for if crashes happen on your device when it’s not hooked up to the debugger. The next time you sync, the crash logs will be copied to /Users/youruser/Library/Logs/CrashReporter/MobileDevice/Your Device Name. You don’t want to bother opening these directly in the console, though–it doesn’t include method names and line numbers. Instead, you want to use a command-line utility called symbolicatecrash to translate the crash log into a version with method names and line numbers. Konstantin Anoshkin’s blog describes the process well–the only change I had to make was that in Xcode 3.2 I now find symbolicatecrash at /Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKit.framework/Versions/A/Resources/symbolicatecrash
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: