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.
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
- Annotate the caller @MainActor or use await MainActor.run
- Make data types Sendable (structs, final classes with immutable state)
- Turn on checking gradually (SWIFT_STRICT_CONCURRENCY = targeted)
Detailed fix by platform
Swift
- swift
func refresh() async { let data = try? await api.fetch() await MainActor.run { self.viewModel.items = data ?? [] } }
How to diagnose
- Isolation — Where is the property isolated?
- Types — Sendable conformance
- 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:
Similar errors
Most viewed in iOS
Other ways to find it
🧠 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026