swift-concurrency-6-2

Migrates Swift code to Swift 6.2 Approachable Concurrency with MainActor defaults and @concurrent offloading.

2|Updated Mar 29, 2015
One-click install
npx skills add https://github.com/ovisan/dotfiles --skill swift-concurrency-6-2-ovisan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swift-concurrency-6-2
Source: https://github.com/ovisan/dotfiles/tree/main/.agents/skills/swift-concurrency-6-2
Command: npx skills add https://github.com/ovisan/dotfiles --skill swift-concurrency-6-2-ovisan

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Swift 6.1 and earlier implicitly offload async functions to background threads, causing data-race compiler errors in seemingly safe code. This Skill guides adoption of Swift 6.2's Approachable Concurrency model, where code stays single-threaded by default and concurrency is introduced explicitly. ## Core Features & Use Cases - Data-Race Error Resolution: Explains why async functions now stay on the calling actor and how this eliminates common "Sending risks causing data races" compiler errors. - Isolated Conformances: Shows how MainActor types conform to non-isolated protocols safely using @MainActor conformances instead of nonisolated workarounds. - Explicit Background Offloading: Covers the @concurrent attribute for moving CPU-intensive work (image processing, compression) to the concurrent thread pool. - Use Case: When migrating an app to Xcode 26 and hitting data-race errors on a @MainActor view model calling a photo processor, apply the patterns here to keep code on the main actor by default and offload only the heavy extraction work with @concurrent. ## Quick Start Ask the AI to migrate my Swift class to Swift 6.2 Approachable Concurrency and fix the data-race errors in my MainActor code.

Frequently Asked Questions about swift-concurrency-6-2

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix "Sending risks causing data races" errors in Swift 6.2?

In Swift 6.2, async functions stay on the calling actor by default, so code that failed in Swift 6.1 often compiles without changes. Enable the Approachable Concurrency build settings in Xcode's Swift Compiler Concurrency section, then recompile.

How do I offload work to a background thread in Swift 6.2?

Mark the containing type as nonisolated, add the @concurrent attribute to the function, ensure it is async, and add await at call sites. Use @concurrent only for CPU-intensive work like image processing or compression after profiling.

What is an isolated conformance in Swift 6.2?

An isolated conformance lets a MainActor type conform to a non-isolated protocol by writing extension MyType: @MainActor SomeProtocol. The compiler guarantees the conformance is only used on the main actor, rejecting use from nonisolated contexts.

Does Swift 6.2 require @MainActor annotations on every class?

No. Swift 6.2 offers an opt-in MainActor default inference mode where classes, properties, and conformances are implicitly @MainActor without annotations. It is recommended for apps, scripts, and other executable targets.

When should I not use @concurrent in Swift?

Avoid applying @concurrent to every async function, since most code does not need background execution. Profile with Instruments first and offload only proven hot paths; otherwise you add complexity without performance benefit.