swift-concurrency-6-2
Swift 6.2 可接近的并发性 — 默认单线程,@concurrent 用于显式后台卸载,隔离一致性用于主 actor 类型。
Content Preview
--- name: swift-concurrency-6-2 description: Swift 6.2 可接近的并发性 — 默认单线程,@concurrent 用于显式后台卸载,隔离一致性用于主 actor 类型。 --- # Swift 6.2 可接近的并发 采用 Swift 6.2 并发模型的模式,其中代码默认在单线程上运行,并发是显式引入的。在无需牺牲性能的情况下消除常见的数据竞争错误。 ## 何时启用 * 将 Swift 5.x 或 6.0/6.1 项目迁移到 Swift 6.2 * 解决数据竞争安全编译器错误 * 设计基于 MainActor 的应用架构 * 将 CPU 密集型工作卸载到后台线程 * 在 MainActor 隔离的类型上实现协议一致性 * 在 Xcode 26 中启用“可接近的并发”构建设置 ## 核心问题:隐式的后台卸载 在 Swift 6.1 及更早版本中,异步函数可能会被隐式卸载到后台线程,即使在看似安全的代码中也会导致数据竞争错误: ```swift // Swift 6.1: ERROR @MainActor final clas
How to Use
Recommended: Install to project (local)
mkdir -p .claude/skills
curl -o .claude/skills/swift-concurrency-6-2.md \
https://raw.githubusercontent.com/affaan-m/everything-claude-code/main/docs/zh-CN/skills/swift-concurrency-6-2/SKILL.mdSkill is scoped to this project only. Add .claude/skills/ to your .gitignoreif you don't want to commit it.
Alternative: Clone full repo
git clone https://github.com/affaan-m/everything-claude-codeThen reference at docs/zh-CN/skills/swift-concurrency-6-2/SKILL.md
Related Skills
swift-actor-persistence
在 Swift 中使用 actor 实现线程安全的数据持久化——基于内存缓存与文件支持的存储,通过设计消除数据竞争。
swift-actor-persistenceswiftactorpersistence
by affaan-m · everything-claude-code
swift-protocol-di-testing
基于协议的依赖注入,用于可测试的Swift代码——使用聚焦协议和Swift Testing模拟文件系统、网络和外部API。
swift-protocol-di-testingswiftprotocoltesting
by affaan-m · everything-claude-code
swift-expert
Builds iOS/macOS/watchOS/tvOS applications, implements SwiftUI views and state management, designs protocol-oriented architectures, handles async/await concurrency, implements actors for thread safety, and debugs Swift-specific issues. Use when building iOS/macOS applications with Swift 5.9+, SwiftUI, or async/await concurrency. Invoke for protocol-oriented programming, SwiftUI state management, actors, server-side Swift, UIKit integration, Combine, or Vapor.
swift-expertswiftexpert
by Jeffallan · jeffallan-claude-skills
swift-macos-expert
Use proactively for Swift and macOS desktop application development, debugging, testing, and architecture. Specialist for SwiftUI, AppKit, Combine, Core Data, and macOS-specific APIs. Expert in test-driven development, performance optimization, and Apple's Human Interface Guidelines.
agentsswiftmacosexpert
by qdhenry · claude-command-suite