KS
Killer-Skills

swift-concurrency-6-2 — how to use swift-concurrency-6-2 how to use swift-concurrency-6-2, swift-concurrency-6-2 tutorial, swift-concurrency-6-2 vs Swift 5.x, swift-concurrency-6-2 install, swift-concurrency-6-2 setup guide, swift-concurrency-6-2 best practices, what is swift-concurrency-6-2, swift-concurrency-6-2 alternative, swift-concurrency-6-2 documentation

Verified
v1.0.0
GitHub

About this Skill

Ideal for iOS Development Agents requiring seamless integration with Swift 6.2's concurrency model for efficient background offloading and data-race safety swift-concurrency-6-2 is a concurrency model in Swift 6.2 that runs code single-threaded by default and introduces concurrency explicitly using @concurrent for background offloading and isolated conformances for main actor types.

Features

Runs code single-threaded by default to eliminate common data-race errors
Introduces concurrency explicitly using @concurrent for background offloading
Supports isolated conformances for main actor types
Helps migrate Swift 5.x or 6.0/6.1 projects to Swift 6.2
Resolves data-race safety compiler errors
Designs MainActor-based app architecture

# Core Topics

affaan-m affaan-m
[62.0k]
[7678]
Updated: 3/6/2026

Quality Score

Top 5%
86
Excellent
Based on code quality & docs
Installation
SYS Universal Install (Auto-Detect)
Cursor IDE Windsurf IDE VS Code IDE
> npx killer-skills add affaan-m/everything-claude-code/swift-concurrency-6-2

Agent Capability Analysis

The swift-concurrency-6-2 MCP Server by affaan-m is an open-source Categories.official integration for Claude and other AI agents, enabling seamless task automation and capability expansion. Optimized for how to use swift-concurrency-6-2, swift-concurrency-6-2 tutorial, swift-concurrency-6-2 vs Swift 5.x.

Ideal Agent Persona

Ideal for iOS Development Agents requiring seamless integration with Swift 6.2's concurrency model for efficient background offloading and data-race safety

Core Value

Empowers agents to offload CPU-intensive work to background threads using @concurrent, implement isolated conformances for main actor types, and design MainActor-based app architectures with Swift 6.2's approachable concurrency, eliminating common data-race errors without sacrificing performance

Capabilities Granted for swift-concurrency-6-2 MCP Server

Migrating existing Swift projects to Swift 6.2 for improved concurrency
Resolving data-race safety compiler errors with explicit background offloading
Designing efficient MainActor-based app architectures for iOS applications
Offloading CPU-intensive tasks to background threads for enhanced performance

! Prerequisites & Limits

  • Requires Swift 6.2 or later
  • Limited to single-threaded execution by default, with explicit concurrency introduction using @concurrent
Project
SKILL.md
7.6 KB
.cursorrules
1.2 KB
package.json
240 B
Ready
UTF-8
SKILL.md
Readonly

Swift 6.2 Approachable Concurrency

Patterns for adopting Swift 6.2's concurrency model where code runs single-threaded by default and concurrency is introduced explicitly. Eliminates common data-race errors without sacrificing performance.

When to Activate

  • Migrating Swift 5.x or 6.0/6.1 projects to Swift 6.2
  • Resolving data-race safety compiler errors
  • Designing MainActor-based app architecture
  • Offloading CPU-intensive work to background threads
  • Implementing protocol conformances on MainActor-isolated types
  • Enabling Approachable Concurrency build settings in Xcode 26

Core Problem: Implicit Background Offloading

In Swift 6.1 and earlier, async functions could be implicitly offloaded to background threads, causing data-race errors even in seemingly safe code:

swift
1// Swift 6.1: ERROR 2@MainActor 3final class StickerModel { 4 let photoProcessor = PhotoProcessor() 5 6 func extractSticker(_ item: PhotosPickerItem) async throws -> Sticker? { 7 guard let data = try await item.loadTransferable(type: Data.self) else { return nil } 8 9 // Error: Sending 'self.photoProcessor' risks causing data races 10 return await photoProcessor.extractSticker(data: data, with: item.itemIdentifier) 11 } 12}

Swift 6.2 fixes this: async functions stay on the calling actor by default.

swift
1// Swift 6.2: OK — async stays on MainActor, no data race 2@MainActor 3final class StickerModel { 4 let photoProcessor = PhotoProcessor() 5 6 func extractSticker(_ item: PhotosPickerItem) async throws -> Sticker? { 7 guard let data = try await item.loadTransferable(type: Data.self) else { return nil } 8 return await photoProcessor.extractSticker(data: data, with: item.itemIdentifier) 9 } 10}

Core Pattern — Isolated Conformances

MainActor types can now conform to non-isolated protocols safely:

swift
1protocol Exportable { 2 func export() 3} 4 5// Swift 6.1: ERROR — crosses into main actor-isolated code 6// Swift 6.2: OK with isolated conformance 7extension StickerModel: @MainActor Exportable { 8 func export() { 9 photoProcessor.exportAsPNG() 10 } 11}

The compiler ensures the conformance is only used on the main actor:

swift
1// OK — ImageExporter is also @MainActor 2@MainActor 3struct ImageExporter { 4 var items: [any Exportable] 5 6 mutating func add(_ item: StickerModel) { 7 items.append(item) // Safe: same actor isolation 8 } 9} 10 11// ERROR — nonisolated context can't use MainActor conformance 12nonisolated struct ImageExporter { 13 var items: [any Exportable] 14 15 mutating func add(_ item: StickerModel) { 16 items.append(item) // Error: Main actor-isolated conformance cannot be used here 17 } 18}

Core Pattern — Global and Static Variables

Protect global/static state with MainActor:

swift
1// Swift 6.1: ERROR — non-Sendable type may have shared mutable state 2final class StickerLibrary { 3 static let shared: StickerLibrary = .init() // Error 4} 5 6// Fix: Annotate with @MainActor 7@MainActor 8final class StickerLibrary { 9 static let shared: StickerLibrary = .init() // OK 10}

MainActor Default Inference Mode

Swift 6.2 introduces a mode where MainActor is inferred by default — no manual annotations needed:

swift
1// With MainActor default inference enabled: 2final class StickerLibrary { 3 static let shared: StickerLibrary = .init() // Implicitly @MainActor 4} 5 6final class StickerModel { 7 let photoProcessor: PhotoProcessor 8 var selection: [PhotosPickerItem] // Implicitly @MainActor 9} 10 11extension StickerModel: Exportable { // Implicitly @MainActor conformance 12 func export() { 13 photoProcessor.exportAsPNG() 14 } 15}

This mode is opt-in and recommended for apps, scripts, and other executable targets.

Core Pattern — @concurrent for Background Work

When you need actual parallelism, explicitly offload with @concurrent:

Important: This example requires Approachable Concurrency build settings — SE-0466 (MainActor default isolation) and SE-0461 (NonisolatedNonsendingByDefault). With these enabled, extractSticker stays on the caller's actor, making mutable state access safe. Without these settings, this code has a data race — the compiler will flag it.

swift
1nonisolated final class PhotoProcessor { 2 private var cachedStickers: [String: Sticker] = [:] 3 4 func extractSticker(data: Data, with id: String) async -> Sticker { 5 if let sticker = cachedStickers[id] { 6 return sticker 7 } 8 9 let sticker = await Self.extractSubject(from: data) 10 cachedStickers[id] = sticker 11 return sticker 12 } 13 14 // Offload expensive work to concurrent thread pool 15 @concurrent 16 static func extractSubject(from data: Data) async -> Sticker { /* ... */ } 17} 18 19// Callers must await 20let processor = PhotoProcessor() 21processedPhotos[item.id] = await processor.extractSticker(data: data, with: item.id)

To use @concurrent:

  1. Mark the containing type as nonisolated
  2. Add @concurrent to the function
  3. Add async if not already asynchronous
  4. Add await at call sites

Key Design Decisions

DecisionRationale
Single-threaded by defaultMost natural code is data-race free; concurrency is opt-in
Async stays on calling actorEliminates implicit offloading that caused data-race errors
Isolated conformancesMainActor types can conform to protocols without unsafe workarounds
@concurrent explicit opt-inBackground execution is a deliberate performance choice, not accidental
MainActor default inferenceReduces boilerplate @MainActor annotations for app targets
Opt-in adoptionNon-breaking migration path — enable features incrementally

Migration Steps

  1. Enable in Xcode: Swift Compiler > Concurrency section in Build Settings
  2. Enable in SPM: Use SwiftSettings API in package manifest
  3. Use migration tooling: Automatic code changes via swift.org/migration
  4. Start with MainActor defaults: Enable inference mode for app targets
  5. Add @concurrent where needed: Profile first, then offload hot paths
  6. Test thoroughly: Data-race issues become compile-time errors

Best Practices

  • Start on MainActor — write single-threaded code first, optimize later
  • Use @concurrent only for CPU-intensive work — image processing, compression, complex computation
  • Enable MainActor inference mode for app targets that are mostly single-threaded
  • Profile before offloading — use Instruments to find actual bottlenecks
  • Protect globals with MainActor — global/static mutable state needs actor isolation
  • Use isolated conformances instead of nonisolated workarounds or @Sendable wrappers
  • Migrate incrementally — enable features one at a time in build settings

Anti-Patterns to Avoid

  • Applying @concurrent to every async function (most don't need background execution)
  • Using nonisolated to suppress compiler errors without understanding isolation
  • Keeping legacy DispatchQueue patterns when actors provide the same safety
  • Skipping model.availability checks in concurrency-related Foundation Models code
  • Fighting the compiler — if it reports a data race, the code has a real concurrency issue
  • Assuming all async code runs in the background (Swift 6.2 default: stays on calling actor)

When to Use

  • All new Swift 6.2+ projects (Approachable Concurrency is the recommended default)
  • Migrating existing apps from Swift 5.x or 6.0/6.1 concurrency
  • Resolving data-race safety compiler errors during Xcode 26 adoption
  • Building MainActor-centric app architectures (most UI apps)
  • Performance optimization — offloading specific heavy computations to background

Related Skills

Looking for an alternative to swift-concurrency-6-2 or building a Categories.official AI Agent? Explore these related open-source MCP Servers.

View All

flags

Logo of facebook
facebook

flags is a feature flag management system that enables developers to check flag states, compare channels, and debug feature behavior differences across release channels.

243.6k
0
Design

extract-errors

Logo of facebook
facebook

extract-errors is a skill that assists in extracting and managing error codes in React applications using yarn extract-errors command.

243.6k
0
Design

fix

Logo of facebook
facebook

fix is a technical skill that resolves lint errors, formatting issues, and ensures code quality in declarative, frontend, and UI projects

243.6k
0
Design

flow

Logo of facebook
facebook

Flow is a type checking system for JavaScript, used to validate React code and ensure consistency across applications

243.6k
0
Design