0

Any of you knows how can I log any crash exception from iOS app?.

I forcing a crash on my viewController:

- (void)viewDidLoad {
    [super viewDidLoad];
    NSArray *myArray = [NSArray new];
    NSLog(@"%@", [myArray objectAtIndex:0]);
}

and I try to capture the crash in the console in my AppDelegate:

void uncaughtExceptionHandler(NSException *exception) {
    NSLog(@"CRASH: %@", exception);
    NSLog(@"Stack Trace: %@", [exception callStackSymbols]);
}

void SignalHandler(int sig) {
    NSLog(@"CRASH: %d",sig);
}

But this didn't work. Any of you knows how can register any crashing exception in iOS?

Dima
  • 23,484
  • 6
  • 56
  • 83
user2924482
  • 8,380
  • 23
  • 89
  • 173

1 Answers1

0

Are you actually setting the exception handler using NSSetUncaughtExceptionHandler?

Something like:

NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);

https://developer.apple.com/reference/foundation/1409609-nssetuncaughtexceptionhandler

Dima
  • 23,484
  • 6
  • 56
  • 83
  • I implemented NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler); and works. But how Can log the output to log ? – user2924482 Sep 26 '16 at 21:14