preconditionFailure

@noreturn func preconditionFailure(_: @autoclosure () -> String, file: StaticString, line: UWord)

Indicate that a precondition was violated.

Use this function to stop the program when control flow can only reach the call if your API was improperly used.

  • In playgrounds and -Onone builds (the default for Xcode's Debug configuration), stop program execution in a debuggable state after printing message.

  • In -O builds (the default for Xcode's Release configuration), stop program execution.

  • In -Ounchecked builds, the optimizer may assume that this function will never be called. Failure to satisfy that assumption is a serious programming error.

Declaration

@noreturn func preconditionFailure(_ message: @autoclosure () -> String = default, file: StaticString = default, line: UWord = default)