I want to implement native crash reporting (without using 3rd party library recommended) in my iOS Swift 4 code and inform to my back end server with API call when the App Crashes or generating any exceptions. I found that App Store / iTunes Connect provides number of Crashes but it does not provide Crash information like from which UIViewController or from due to which error it crashed. Could anyone help me out in this? Thanks in advance.
EXC_BREAKPOINT (SIGTRAP) and EXC_BAD_INSTRUCTION (SIGILL)The breakpoint exception type indicates a trace trap interrupted the process. A trace trap gives an attached debugger the chance to interrupt the process at a specific point in its execution. On ARM processors, this appears as EXC_BREAKPOINT (SIGTRAP).
try – You must use this keyword in front of the method that throws. Think of it like this: “You're trying to execute the method. catch – If the throwing method fails and raises an error, the execution will fall into this catch block. This is where you'll write code display a graceful error message to the user.
Yes for that you have to make your custom crash report manager and you can use NSSetUncaughtExceptionHandler
for getting the crash report stack.
Example
NSSetUncaughtExceptionHandler { exception in
print(exception)
print(exception.callStackSymbols)
// Write callStackSymbols into the file
// Call your mail function with that file
// mail()
}
let array = NSArray()
let element = array.object(at: 4)
You can write that Crash Report into the file and mail it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With