views:

558

answers:

9

I'm working on a Cocoa app targeting Leopard and above, and I'm thinking about adding a crash reporter to it (I'd like to think my app won't crash, but let's get real here). I have some mostly conceptual questions before I really get started.

1) How does this work conceptually, knowing when there's a crash and bringing up a reporter? Do I have a daemon running looking for a crash, or do I wait until my app is launched next time to report?

2) Can this be done in Cocoa? Or would I have to dip into Carbon or IOKit or somesuch?

3) Is this even a good idea? Mac OS X already has a built in crash reporter, but as a developer I don't get to see the crash logs. I don't think my app will be crashing often, frankly, but I just don't want to be naive but this sort of thing.

What are your thoughts and opinions regarding this?

+2  A: 

http://developer.apple.com/technotes/tn2004/tn2123.html

http://www.smartcrashreports.com/

http://code.google.com/p/plcrashreporter/

And for your next question:

http://sparkle.andymatuschak.org/

Stephen Hoffman
Sparkle sure is a blessing, isn't it? It's already in my project, but it's a good suggestion for others too.
jbrennan
+1  A: 

I have seen a few apps use Smart Crash Reporter or perhaps some variant of it. When your application crashes, it will bring up the usual Apple crash dialog with an extra button which says "Send to both Apple and You"

sigjuice
+1  A: 

I would shy away from Smart Crash Reporter for the single reason that it has a bad taste for a lot of users, and is a good way to get bad press for your app (deserved or not) PLCrashReporter or UKCrashReporter http://zathras.de/angelweb/sourcecode.htm they will give some ideas about what to do and how to do it in ways that don't inject into other code space.

Sam D
+4  A: 

I've had a lot of success with UKCrashReporter. The code is straighforward and easy to modify to match the L&F of your app.

PLCrashReporter looks interesting, though.

I'd stay away from Smart Crash Reporter just because many users (rightfully) don't appreciate your app injecting code into unexpected places and it strikes me as a fragile (perhaps dangerous to use in a released app) approach.

Barry Wark
+1  A: 

Others have answered the question well and pointed to some good example code.

Coding it yourself is fairly simple. The strategy generally is:

  • catch appropriate signals
  • launch a separate crash reporter app that lives inside your application's bundle
  • the crash reporter app then finds the latest crash log entry for your app and sends it to you via whatever method you desire (POST, email, etc)
Wade Williams
A: 

Another option is Google's Breakpad. It has a Cocoa framework wrapper, and is compatible with Mozilla's Socorro server. It's used by Firefox, and the Cocoa framework is used in the current betas of Camino. The client-side integration is pretty easy, but I've never looked at what it takes to run an instance of the Socorro server.

smorgan
+2  A: 

I've also rolled my own: SFBCrashReporter

There is a small post on my blog about it.

sbooth
I've used this in my app and was quite happy with it. The current version is designed for GC-enabled apps, though, so using it for non-GC apps requires a small amount of tweaking. I tried UKCrashReporter as well but liked this better.
hasseg
+2  A: 

Daniel Jalkut has a blog post about this issue that I found very informative.

Rui Pacheco
A: 

I'm using ILCrashReporter and it works really nicely. The method is email based so it works well with Fogbugz.

Ian Turner
ILCrashReporter is not working on snow leopard ... any clue?
Miraaj