I want to be able to set a global function in my app delegate so I can log all uncaught exceptions.
Is there a way I can catch all uncaught exceptions, so I can log them to a file? I already have the file being created so I just need and way to call a method for unhandled exceptions.
While there are some quick solutions to this (
NSUncaughtExceptionHandlerand the like), handling all the cases that you likely want to handle is quite complex. For instance, I assume you really want to catch crashes due to signals (SEGV), not just crashes due to ObjC exceptions.IMO, this is not something you want to build from scratch. Use a framework designed for it. My favorite frameworks for solving this are PLCrashReporter and QuincyKit (which uses PLCrashReporter).