Xcode 9.1 Improves Display of Fatal Errors

Swift has language constructs that allow you to specify your program’s expectations. If these expectations are not met at runtime, the program will be terminated.

When the expectations are incorrect or when there’s a bug in the code, Swift guarantees that the program will trap. Especially during development it’s common that some precondition isn’t met, the program terminates and the debugger will show that. However, prior to Xcode 9.1 (currently available as a beta), the debugger displayed these situations just as any other type of crash — usually as EXC_BAD_INSTRUCTION or EXC_BREAKPOINT (which are the low-level Mach exceptions types).

swift.org/blog/xcode-9.1-improves-display-of-fatal-errors/

Swift has features that let you set expectations in your code. If these are not met at runtime, the program stops. Examples include array indexing, forced unwraps of optionals, and preconditions.

Before Xcode 9.1, the debugger showed these failures as general crashes. Now, it shows the exact reason for the failure in the editor at the point where the trap happened. This covers cases like unwrapping nil, out-of-bounds access, and assertion failures, but only if the app starts in Swift.


Category:

Year: