<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Actor/assertIsolated(_:file:line:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:ScA12_ConcurrencyE14assertIsolated_4file4lineySSyXK_s12StaticStringVSutF"
  },
  "title" : "assertIsolated(_:file:line:)"
}
-->

# assertIsolated(_:file:line:)

Stops program execution if the current task is not executing on this
actor’s serial executor.

```
@backDeployed(before: macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0)
nonisolated func assertIsolated(_ message: @autoclosure () -> String = String(), file: StaticString = #fileID, line: UInt = #line)
```

## Parameters

`message`

The message to print if the assertion fails.

`file`

The file name to print if the assertion fails. The default is
where this method was called.

`line`

The line number to print if the assertion fails The default is
where this method was 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), stops program execution in a debuggable state after
  printing `message`.
- In `-O` builds (the default for Xcode’s Release configuration),
  the isolation check is not performed and there are no effects.

> Note: This check is performed against the actor’s serial executor,
> meaning that / if another actor uses the same serial executor–by using
> that actor’s serial executor as its own ``doc://com.apple.Swift/documentation/Swift/Actor/unownedExecutor``–this
> check will succeed , as from a concurrency safety perspective, the
> serial executor guarantees mutual exclusion of those two actors.

---

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)