swift-concurrency-expert
Installation
SKILL.md
Swift Concurrency Expert
Overview
Swift's data-race safety is a set of compile-time rules about isolation: every piece of mutable state belongs to one actor, one task, or nobody (immutable), and values may cross between those domains only when that cannot produce concurrent access. Almost every concurrency diagnostic says the same thing in different words: "this value can be reached from two domains at once". The job is to make the isolation true with the smallest change, and to avoid changes that only silence the compiler. This skill covers reading the configuration, mapping a diagnostic to its cause, choosing a fix, and confirming it with a build.
Instructions
1. Read the configuration before reading the code
The same file compiles differently depending on five settings. Find them first and quote them in your answer.
| What | Xcode build setting | Package.swift (swiftSettings) |
Compiler flag |
|---|---|---|---|
| Language mode | SWIFT_VERSION = 6 |
.swiftLanguageMode(.v6), or tools version 6.0+ |
-swift-version 6 |
| Checking level in Swift 5 mode | SWIFT_STRICT_CONCURRENCY = complete |
.enableUpcomingFeature("StrictConcurrency") |
-strict-concurrency=complete |
| Default isolation (6.2) | SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor |
.defaultIsolation(MainActor.self) |
-default-isolation MainActor |
| Async functions stay on the caller's actor (6.2) | SWIFT_UPCOMING_FEATURE_NONISOLATED_NONSENDING_BY_DEFAULT |
.enableUpcomingFeature("NonisolatedNonsendingByDefault") |
-enable-upcoming-feature NonisolatedNonsendingByDefault |
| Bundle of the 6.2 usability features | SWIFT_APPROACHABLE_CONCURRENCY |
each feature by name | each feature by name |