I have an iOS application written in Swift 2 in Xcode 8.2.1, built for iOS 10.2.
I had several crash reports from TestFlight and, despite the symbolism, none of the crash logs shows any state of the program except for the stack trace (without argument values, without locales, without heap objects, etc.).
... but inside these functions I see code that most likely will not work (for example, forced reversal), but the crash log does not tell me where and why it does not work.
When debugging in Xcode, I can use fatalError(message: String) , where I can put my own message, for example, "functionFoo returned nil" or "variable bar == \"" + bar + "\"" , unless it is deployed using TestFlight or the App Store fatalError , and the program terminates, but the message value is not stored in the fault log, which makes it meaningless.
In other environments, such as C # /. NET and Java, I can just throw new SomeExceptionType("my message") , and all the information is available in any global catch(Exception) handler that I have.
How can I achieve the same goal in iOS / Swift?
source share