swift-concurrency-6-2

Eliminate implicit background offloading and data races in Swift 6.2 async code.

1|Updated Apr 7, 2026
One-click install
npx skills add https://github.com/riftzen-bit/gemini-setup --skill swift-concurrency-6-2-riftzen-bit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swift-concurrency-6-2
Source: https://github.com/riftzen-bit/gemini-setup/tree/main/skills/swift-concurrency-6-2
Command: npx skills add https://github.com/riftzen-bit/gemini-setup --skill swift-concurrency-6-2-riftzen-bit

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill addresses implicit background offloading and resulting data races in Swift async code by describing how to adopt Swift 6.2's single-thread-by-default model and avoid actor isolation pitfalls so your UI and shared state remain safe and deterministic.

Core Features & Use Cases

  • Single-thread-by-default guidance: explains how async calls remain on the calling actor in Swift 6.2 to prevent accidental offloading.
  • Isolated conformances and MainActor patterns: shows how MainActor types can safely conform to non-isolated protocols and how to protect global/static state.
  • Explicit background offloading with @concurrent: details when to mark types nonisolated, annotate functions with @concurrent, and apply await at call sites for CPU-bound work.
  • Migration checklist and settings: stepwise instructions for enabling MainActor inference in Xcode and SwiftPM, using migration tooling, and validating changes with tests and profiling.
  • Use cases: migrating legacy Swift projects, designing MainActor-centric app architectures, and offloading image processing or heavy computations safely.

Quick Start

Migrate a module to Swift 6.2 by enabling MainActor inference in your build settings, audit actor-isolated globals and protocol conformances, profile hot paths, and add @concurrent to CPU-bound functions where needed.

Frequently Asked Questions about swift-concurrency-6-2

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

FAQPage Schema
How does Swift 6.2 concurrency prevent data races in async code?

Swift 6.2 concurrency prevents data races by adopting a single-thread-by-default model where async calls remain on the calling actor, eliminating implicit background offloading and protecting shared state.

How do I migrate a project to Swift 6.2 concurrency in Xcode?

To migrate to Swift 6.2 concurrency, enable MainActor inference in your Xcode or SwiftPM build settings, audit actor-isolated globals and protocol conformances, profile hot paths, and apply @concurrent to CPU-bound functions.

When should I use @concurrent in Swift async code?

Use @concurrent in Swift async code when offloading CPU-bound work like heavy computations or image processing, ensuring functions are marked nonisolated and called with await to maintain safe background execution.

Can MainActor types conform to non-isolated protocols in Swift 6.2?

MainActor types can safely conform to non-isolated protocols in Swift 6.2 by documenting isolated conformances and applying single-thread-by-default semantics to protect global and static state.

Why does Swift 6.2 async code remain on the calling actor?

Swift 6.2 async code remains on the calling actor to enforce single-thread-by-default semantics, preventing accidental background offloading and ensuring UI and shared state remain deterministic and safe.

What are the limitations of MainActor-centric architectures in Swift?

MainActor-centric architectures in Swift require explicit @concurrent annotations for CPU-bound background offloading and careful auditing of global state to avoid data races during migration.