DevPrep

All topics › Swift Concurrency (async/await, actors)

What does Swift 6 strict concurrency checking change?

Senior PRO

The essence

Swift 6 language mode makes a data race a compile error. The compiler tracks isolation boundaries (actors, tasks, @Sendable closures) and requires that everything crossing them be Sendable or provably "disconnected" (region-based isolation, sending). Global and static vars must be isolated to an actor, immutable, or marked nonisolated(unsafe). A whole class of bugs moves from runtime (TSan, rare crashes) to compile time.

The checking level is set by Strict Concurrency Checking: minimal → targeted → complete (warnings in Swift 5 mode), and switching Swift Language Version to 6 turns them into errors. Migration tools: @preconcurrency import (silences errors from un-migrated modules), @unchecked Sendable, nonisolated(unsafe), MainActor.assumeIsolated, wrapping legacy APIs in @MainActor.

The rest of this answer, with code and interview follow-ups, is in the DevPrep app.

Read the full answer in DevPrep

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store