Migrating to Swift 6
Overview
Swift’s concurrency system, introduced in Swift 5.5, makes asynchronous and parallel code easier to write and understand. With the Swift 6 language mode, the compiler can now guarantee that concurrent programs are free of data races. When enabled, compiler safety checks that were previously optional become required.
Adopting the Swift 6 language mode is entirely under your control on a per-target basis. Targets that build with previous modes, as well as code in other languages exposed to Swift, can all interoperate with modules that have been migrated to the Swift 6 language mode.
It is possible you have been incrementally adopting concurrency features as they were introduced. Or, you may have been waiting for the Swift 6 release to begin using them. Regardless of where your project is in this process, this guide provides concepts and practical help to ease the migration.
You will find articles and code examples here that:
Explain the concepts used by Swift’s data-race safety model.
Outline a possible way to get started with migration.
Show how to enable complete concurrency checking for Swift 5 projects.
Demonstrate how to enable the Swift 6 language mode.
Present strategies to resolve common problems.
Provide techniques for incremental adoption.
Contributing
This guide is under active development. You can view the source, see full code examples, and learn about how to contribute in the repository. We would love your contributions in the form of:
Filing issues to cover specific code patterns or additional sections of the guide
Opening pull requests to improve existing content or add new content
Reviewing others’ pull requests for clarity and correctness of writing and code examples
For more information, see the contributing document.
Topics
Data Race SafetyMigration StrategyEnable data-race safety checkingCommon Compiler ErrorsIncremental AdoptionMigrating to upcoming language featuresSource CompatibilityLibrary Evolution