preconditionFailure

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

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(@autoclosure message: () -> String = default, file: StaticString = #file, line: UInt = #line)