<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/assertionFailure(_:file:line:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s16assertionFailure_4file4lineySSyXK_s12StaticStringVSutF"
  },
  "title" : "assertionFailure(_:file:line:)"
}
-->

# assertionFailure(_:file:line:)

Indicates that an internal consistency check failed.

```
func assertionFailure(_ message: @autoclosure () -> String = String(), file: StaticString = #file, line: UInt = #line)
```

## Parameters

`message`

A string to print in a playground or `-Onone` build. The
default is an empty string.

`file`

The file name to print with `message`. The default is the file
where `assertionFailure(_:file:line:)` is called.

`line`

The line number to print along with `message`. The default is the
line number where `assertionFailure(_:file:line:)` is called.

## Discussion

This function’s effect varies depending on the build flag 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, has no effect.
- In `-Ounchecked` builds, the optimizer may assume that this function is
  never called. Failure to satisfy that assumption is a serious
  programming error.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)