Main actor-isolated iOS Origin: On your device Last updated 13 Oct 2026

Swift 6: Main actor-isolated property 'x' can not be referenced from a nonisolated context / Sending 'x' risks causing data races

Strict concurrency checking found code that accesses main-actor state from another isolation domain, or passes non-Sendable values across actors.

Exact message you may see Main actor-isolated property can not be referenced from a nonisolated contextSending risks causing data racesCapture of non-sendable typeCall to main actor-isolated instance method in a synchronous nonisolated context
Seen on: iOS

Meaning

Swift 6 language mode (and complete checking in Swift 5.10) enforces actor isolation and Sendable at compile time. Fix by isolating code to @MainActor, using await, making types Sendable, or restructuring ownership.

Common causes

  • Calling @MainActor APIs from nonisolated functions/closures
  • Passing non-Sendable classes into Tasks/actors
  • Global mutable state
  • Delegates/callbacks from frameworks not annotated

⚡ Quick fix

  1. Annotate the caller @MainActor or use await MainActor.run
  2. Make data types Sendable (structs, final classes with immutable state)
  3. Turn on checking gradually (SWIFT_STRICT_CONCURRENCY = targeted)

Detailed fix by platform

Swift

  1. swift
    func refresh() async {
        let data = try? await api.fetch()
        await MainActor.run { self.viewModel.items = data ?? [] }
    }

How to diagnose

  1. Isolation — Where is the property isolated?
  2. Types — Sendable conformance
  3. Mode — Swift 6 or 5 with complete checking?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

all goroutines are asleep - deadlock — Go: fatal error: all goroutines are asleep - deadlock! (Go)all goroutines are as…Cannot convert value of type — Swift: Cannot convert value of type 'X' to expected argument type 'Y' (iOS)Cannot convert value …Could not cast value of type — Swift: Could not cast value of type 'X' to 'Y' (iOS)Could not cast value …Escaping closure captures mutating 'self' — Swift: Escaping closure captures mutating 'self' parameter (iOS)Escaping closure capt…Index out of range — Swift: Fatal error: Index out of range (iOS)Index out of rangeis only available in iOS x or newer — Swift: 'X' is only available in iOS 16.0 or newer (iOS)is only available in …Main Thread Checker — Main Thread Checker: UI API called on a background thread: -[UIView setNeedsLayout] (iOS)Main Thread CheckerPublishing changes from background threads — SwiftUI: Publishing changes from background threads is not allowed; make sure to publish values from the main thread (iOS)Publishing changes fr…Main acto…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.