Swift: Escaping closure captures mutating 'self' parameter
A mutating method of a struct tries to capture self in an escaping closure, which Swift forbids.
Seen on:
iOS
Meaning
Value types are copied; an escaping closure can’t keep a reference to a mutating struct. Use a class (reference type), @State/ObservableObject in SwiftUI, or capture the needed values instead.
Common causes
- Struct method with async/escaping closure modifying self
- SwiftUI view struct mutating properties in callbacks
⚡ Quick fix
- Move the logic into a class / ObservableObject
- Capture values, not self
- Use @State and update via the main actor
Detailed fix by platform
Swift
- swift
@MainActor final class Loader: ObservableObject { @Published var items: [Item] = [] func load() { Task { items = try await api.fetch() } } }
How to diagnose
- Type — Struct or class?
- Closure — Escaping?
🔧 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