PLCrashReporter – Crash Dump Capture/Reporting for MacOSX & iPhone
Code Quality: Production (used in many OSX and iPhone apps)
PLCrashReporter is an Objective-C framework (on MacOSX) and a static library (on iPhoneOS) that allows you to capture application crash dumps and send them back to yourself for analysis. PLCrashReporter is implemented as an in-process signal handler that can handle both fatal errors (segmentation faults, bus errors and other low-level Unix crashes) as well as Objective-C exceptions and errors. It captures the state of the running process at the time of the crash including backtraces for all active threads, register states, etc.
It is supported on MacOSX 10.5+, and iPhoneOS 2.0+ and takes all of 5 lines of code + one custom method to implement: Just add the framework (or the static library if on iPhoneOS) to your project, and create an instance of the crash reporter in your app delegate and check to see if your app crashed the last time it ran. The “one custom method” is up to you — it’s what you are going to do with the crash report if there is one. Once you get the crash dumps off of the users machine (or iPhone) PLCrashReporter has a tool that decodes the crash dump and allows you to see exactly where your application crashed using the dSYM files created by Xcode when it links your application.
As a practical note, if you want to support this level of crash analysis, you’ll need to save the Xcode dSYM bundles from every build you release so that you can match up the crash dump files with the right build you’re going to debug. XCode’s dSYM files are actually unique per-build so merely pulling a certain version/branch of your code from your repository and re-compiling will not result in a dSYM bundle that will work with a given crash report. Making sure you save/archive dSYM bundles for each builds is a whole process in and of itself and is non-trivial, however Marcus Zarra, who is a very well-known Cocoa developer, explains the process over on his blog Cocoa Is My Girlfriend and even provides a set of scripts you can customize to get this set up in your own development work-flow.
In terms of processing/sending crash reports, Fuller’s demo code has a minimal example of how to handle crash reports, but over on GitHub Andreas Linde has contributed a demo project that shows how to use PLCrashRporter to capture, send, and process crash reports back to/on your own server over the Internet in a form that can pretty much be dropped into any production support system with minor customization.