<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: -",
    "watchOS: 3.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Dispatch",
  "identifier" : "/documentation/Dispatch/dispatchPrecondition(condition:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Dispatch"
    ],
    "preciseIdentifier" : "s:8Dispatch20dispatchPrecondition9conditionyAA0A9PredicateOyXK_tF"
  },
  "title" : "dispatchPrecondition(condition:)"
}
-->

# dispatchPrecondition(condition:)

Checks a dispatch condition necessary for further execution.

```
func dispatchPrecondition(condition: @autoclosure () -> DispatchPredicate)
```

## Parameters

`condition`

A dispatch predicate for the current context to check.

## Discussion

Use this function to detect conditions about the current execution context that must prevent the program from proceeding even in shipping code.

- In playgrounds and `-Onone` builds (the default for Xcode’s Debug configuration): if `condition` evaluates to `false`, stop program execution in a debuggable state.
- In `-O` builds (the default for Xcode’s Release configuration): if `condition` evaluates to `false`, stop program execution.
- In `-Ounchecked` builds, `condition` is not evaluated, but the optimizer may assume that it would evaluate to `true`. Failure to satisfy that assumption in `-Ounchecked` builds 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)