How do you print out a stack trace to the console/log in Cocoa?-Collection of common programming errors
I found this to be exactly what I needed: Puts a catch in the main.m class and prints the stack trace. I am not sure it works in all situations, e.g. not sure this will work when there’s a C level crash. But, better than nothing, and easy to install.
http://blog.evergizmo.com/2012/01/17/objective-c-tip-how-to-print-stack-trace/
In case the link goes away – put this in main.m:
#import
int main(int argc, char *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal;
@try
{
retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");
}
@catch (NSException *exception)
{
NSLog(@"Gosh!!! %@", [exception callStackSymbols]);
@throw;
}
@finally
{
[pool release];
}
return retVal;
}