Iphone – Easy way to print current stack trace of an app

cocoa-touchdebuggingiphoneuikitxcode

Xcode / objective c does not really print a useful stack trace. My app crashes somewhere, and the damn thing gives me only numbers like 45353453, 34524323, 6745345353, 457634524234. Not useful at all.

So I want to make a NSLog(); on the beginning of EVERY method I have in my entire app. But maybe there's a simpler way to just find out the real stack trace, humanly readable? Not only on app launch or crash, but all the time, on every activity that happens? Would help debugging a lot.

Best Solution

Something like this might be helpful to you as well


@implementation UIApplication (MyCategory)

+ (void)logStackTrace {
    @try {
        [[NSException exceptionWithName:@"Stack Trace" reason:@"Testing" userInfo:nil] raise];
    }
    @catch (NSException *e) {
        NSLog(@"%@", [e callStackSymbols]);
    }
}

@end