Skill站外收录 @skilllib/skill-2014279380267118594
axiom-ios-concurrency
提供 iOS 平台 Swift 并发编程的系统性支持,覆盖 async/await 实现、@MainActor 隔离、Sendable 安全性保障、数据竞争预防及 Swift 6 迁移等核心场景,尤其擅长诊断主线程阻塞导致的界面冻结问题。
软件开发 AI 技能
Skills.MD
# iOS Concurrency Router
**You MUST use this skill for ANY concurrency, async/await, threading, or Swift 6 concurrency work.**
## When to Use
Use this router when:
- Writing async/await code
- Seeing concurrency errors (data races, actor isolation)
- Working with @MainActor
- Dealing with Sendable conformance
- Optimizing Swift performance
- Migrating to Swift 6 concurrency
- **App freezes during loading** (likely main thread blocking)
## Conflict Resolution
**ios-concurrency vs ios-performance**: When app freezes or feels slow:
1. **Try ios-concurrency FIRST** — Main thread blocking is the #1 cause of UI freezes. Check for synchronous work on @MainActor before profiling.
2. **Only use ios-performance** if concurrency fixes don't help — Profile after ruling out obvious blocking.
**ios-concurrency vs ios-build**: When seeing Swift 6 concurrency errors:
- **Use ios-concurrency, NOT ios-build** — Concurrency errors are CODE issues, not environment issues
- ios-build is for "No such module", simulator issues, build failures unrelated to Swift language errors
**Rationale**: A 2-second freeze during data loading is almost always `await` on main thread or missing background dispatch. Domain knowledge solves this faster than Time Profiler.
## Routing Logic
### Swift Concurrency Issues
**Swift 6 concurrency patterns** → `/skill axiom-swift-concurrency`
- async/await patterns
- @MainActor usage
- Actor isolation
- Sendable conformance
- Data race prevention
- Swift 6 migration
**Swift performance** → `/skill axiom-swift-performance`
- Value vs reference types
- Copy-on-write optimization
- ARC overhead
- Generic specialization
- Collection performance
**Synchronous actor access** → `/skill axiom-assume-isolated`
- MainActor.assumeIsolated
- @preconcurrency protocol conformances
- Legacy delegate callbacks
- Testing MainActor code synchronously
**Thread-safe primitives** → `/skill axiom-synchronization`
- Mutex (iOS 18+)
- OSAllocatedUnfairLock (iOS 16+)
- Atomic types
- Lock vs actor decision
**Parameter ownership** → `/skill axiom-ownership-conventions`
- borrowing/consuming modifiers
- Noncopyable types (~Copyable)
- ARC traffic reduction
- consume operator
**Concurrency profiling** → `/skill axiom-concurrency-profiling`
- Swift Concurrency Instruments template
- Actor contention diagnosis
- Thread pool exhaustion
- Task visualization
## Decision Tree
```
User asks about concurrency
├─ Concurrency errors?
│ ├─ Data races? → swift-concurrency
│ ├─ Actor isolation? → swift-concurrency
│ ├─ @MainActor? → swift-concurrency
│ └─ Sendable? → swift-concurrency
│
├─ Writing async code? → swift-concurrency
│
├─ assumeIsolated questions? → assume-isolated
│
├─ Mutex/lock/synchronization? → synchronization
│
├─ borrowing/consuming/ownership? → ownership-conventions
│
├─ Profile async performance? → concurrency-profiling
│
└─ Performance optimization? → swift-performance
```
## Critical Patterns
**Swift 6 Concurrency** (swift-concurrency):
- Progressive journey: single-threaded → async → concurrent → actors
- @concurrent attribute for forced background execution
- Isolated conformances
- Main actor mode for approachable concurrency
- 11 copy-paste patterns
**Swift Performance** (swift-performance):
- ~Copyable for non-copyable types
- Copy-on-write (COW) patterns
- Value vs reference type decisions
- ARC overhead reduction
- Generic specialization
## Example Invocations
User: "I'm getting 'data race' errors in Swift 6"
→ Invoke: `/skill axiom-swift-concurrency`
User: "How do I use @MainActor correctly?"
→ Invoke: `/skill axiom-swift-concurrency`
User: "My app is slow due to unnecessary copying"
→ Invoke: `/skill axiom-swift-performance`
User: "Should I use async/await for this network call?"
→ Invoke: `/skill axiom-swift-concurrency`
User: "How do I use assumeIsolated?"
→ Invoke: `/skill axiom-assume-isolated`
User: "My delegate callback runs on main thread, how do I access MainActor state?"
→ Invoke: `/skill axiom-assume-isolated`
User: "Should I use Mutex or actor?"
→ Invoke: `/skill axiom-synchronization`
User: "What's the difference between os_unfair_lock and OSAllocatedUnfairLock?"
→ Invoke: `/skill axiom-synchronization`
User: "What does borrowing do in Swift?"
→ Invoke: `/skill axiom-ownership-conventions`
User: "How do I use ~Copyable types?"
→ Invoke: `/skill axiom-ownership-conventions`
User: "My async code is slow, how do I profile it?"
→ Invoke: `/skill axiom-concurrency-profiling`
User: "I think I have actor contention, how do I diagnose it?"
→ Invoke: `/skill axiom-concurrency-profiling`
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「axiom-ios-concurrency」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次