问题
I am developing an app in which I have to track crashes. There is a restriction that I can't use any third party source like Twitter's Fabric framework to handle crash logging.
Currently I am only able to get the reason for crash. I am not able to get the exact point of crash.
What I am doing:
In my app delegate's didFinishLaunchingWithOptions
method I had made my own exception handler:
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
uncaughtExceptionHandler ----
void uncaughtExceptionHandler(NSException *exception) {
NSLog(@"CRASH: %@", exception);
NSLog(@"callStackSymbols: %@", [exception callStackSymbols]);
NSLog(@"callStackReturnAddresses: %@", [exception callStackReturnAddresses]);
NSLog(@"reason: %@", [exception reason]);
NSLog(@"name: %@", [exception name]);
NSLog(@"%s %d %s %s", __FILE__, __LINE__, __PRETTY_FUNCTION__, __FUNCTION__);
// Internal error reporting
}
I crashed my app in viewDidLoad
method using this:
NSArray *myary;
myary = [NSArray arrayWithObjects:@"sad", nil];
NSString *str = [myary objectAtIndex:22];
Here is my Stack Trace.
Is their any way to achieve what I want?
I tried following these solutions from SO but they don't give me any lead:
Solution 1
Solution 2
来源:https://stackoverflow.com/questions/37998489/how-to-get-line-number-method-name-and-class-name-when-crash-occurs-using-obje