Hi to everyone reading this post.
I've got a requirement to catch all exceptions that are occuring in iOS app and log them to file and eventually send them to back-end server used by the app.
I've been reading about this topic and found one way to this but I'm not sure if it's gonna break App Store Review guideliness.
In AppDelegate I've added following:
NSSetUncaughtExceptionHandler { (exception) in
log.error(exception.callStackSymbols.prettyPrinted())
}
signal(SIGABRT) { s in
log.error(Thread.callStackSymbols.prettyPrinted())
exit(s)
}
signal(SIGILL) { s in
log.error(Thread.callStackSymbols.prettyPrinted())
exit(s)
}
signal(SIGSEGV) { s in
log.error(Thread.callStackSymbols.prettyPrinted())
exit(s)
}
And then when something like this occurs it should catch that error, log it to file and exit the app with signal code that is received.
Questions:
- Is this good approach at all?
- Will it break App Store Review guidelines because of usage of exit()? Is it better to use kill(getpid(), SIGKILL) instead?
- callStackSymbols are not symbolicated, is there a way to symbolicate callStackSymbols?