Swift 6.2 introduces strict compile-time concurrency checking with async/await, actors, and Sendable constraints that prevent data races at compile time instead of runtime. This is the foundation of safe concurrent Swift.
Modern Swift replaces older concurrency patterns (completion handlers, DispatchQueue, locks) with compiler-enforced safety. The core principle: if it compiles with strict concurrency enabled, it cannot have data races.
| Async operation | async/await | Completion handlers | | Main thread work | @MainActor | DispatchQueue.main | | Shared mutable state | actor | Locks, serial queues | | Parallel tasks | TaskGroup | DispatchGroup | | Thread safety | Sendable | @unchecked everywhere |
Da utilizzare quando si scrive codice asincrono/in attesa, si abilita la concorrenza rigorosa, si correggono errori inviabili, si esegue la migrazione da gestori di completamento, si gestisce lo stato condiviso con gli attori o si utilizza Task/TaskGroup per la concorrenza. Fonte: johnrogers/claude-swift-engineering.