Indicates that a precondition was violated.
func preconditionFailure(_ message: @autoclosure () -> String = String(), file: StaticString = #file, line: UInt = #line) -> Never
A string to print in a playground or
-Ononebuild. The default is an empty string.
The file name to print with
message. The default is the file where
The line number to print along with
message. The default is the line number where
Use this function to stop the program when control flow can only reach the call if your API was improperly used and execution flow is not expected to reach the call—for example, in the
default case of a
switch where you have knowledge that one of the other cases must be satisfied.
This function’s effect varies depending on the build flag used:
In playgrounds and
-Ononebuilds (the default for Xcode’s Debug configuration), stops program execution in a debuggable state after printing
-Obuilds (the default for Xcode’s Release configuration), stops program execution.
-Ouncheckedbuilds, the optimizer may assume that this function is never called. Failure to satisfy that assumption is a serious programming error.