I have an iOS application written in Swift 2 in Xcode 8.2.1, that's built for iOS 10.2.
I've had a number of crash reports from TestFlight and despite symbolication, none of the crash logs show any program state besides the stack-traces (no argument values, no locals, no heap objects, etc).
...but inside those functions I can see code which is likely to fail (e.g. a forced unwrap) but the crash log isn't telling me where or why it's failing.
When debugging in Xcode, I can use fatalError(message: String)
where I can put my own message like "functionFoo returned nil"
or "variable bar == \"" + bar + "\""
, except when deployed using TestFlight or the App Store the fatalError
will be hit and the program terminates, but the message
value is not saved to the crash log, making it pointless.
In other environments, like C#/.NET and Java I can simply throw new SomeExceptionType("my message")
and all information is available in whatever global catch(Exception)
handler I have.
How can I achieve the same goal in iOS / Swift?