swift-

Solid

专为 iOS/macOS 现代开发打造的代码分析规范。全面剖析 SwiftUI 响应式模式、ARC 强引用循环破除、以及 Swift 5.5+ 下基于 Actor 与 async/await 的全新并发架构。

AI & Automation 40 stars 8 forks Updated today

Install

View on GitHub

Quality Score: 77/100

Stars 20%
54
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
0
Description 5%
100

Skill Content

# Swift 静态分析与现代化架构生态 (Swift 5.9+) ## 概述 Swift 自从取代 Objective-C 以来,经过多年迭代已经成为了一门兼具安全、极速与表现力的现代语言。由于深度绑定 Apple 生态圈,它的开发范式经历了从 UIKit Delegate 时代到现代 **SwiftUI** 与 **Combine** 声明式的巨大转变。 同时,自 Swift 5.5 引入的 **Structured Concurrency (结构化并发, async/await)** 和 **Actors** 打破了长期统治苹果开发生态的 GCD (Grand Central Dispatch / DispatchQueue) 回调地狱。然而,伴随着 `closures` (闭包) 和 `class` 的大量混用,ARC 面临的最大隐性克星 —— **强引用循环 (Retain Cycles)** 导致内存泄漏 (Memory Leak) 在项目中依然屡见不鲜。 **核心原则**: "防微杜渐,声明优先"。对所有的引用传递敲打问号;在跨越系统边界处主动斩断强依赖树;摒弃手动维护状态,使 UI 只做驱动模型状态的反射。 ## 何时使用 **始终:** - 开发苹果全家桶原生应用 (iOS / macOS / visionOS / watchOS)。 - 维护或升级使用了老旧 `@escaping` 闭包和 `NotificationCenter` 的陈旧代码库。 - 将复杂交互迁移至 `SwiftUI` 响应式视图体系。 - 解决 Xcode Memory Graph 发出的交叉持有的警告并排查由于 Navigation 引发的爆内存退场。 **触发短语:** - "如何解决 Swift 闭包里的 Retain Cycle 并优化 weak self 用法?" - "推荐一些从 GCD 迁移到 Swift async/await 的最佳实践。" - "SwiftUI 里面 @State, @Binding 和 @Observable 怎么区分,不要乱用?" - "Actor 怎么避免 Swift 里的数据竞态 (Data Race)?" - "如何优化 Swift 的编译速度和庞大项目结构?" - "请给我一个 iOS Clean Architecture 或 MVVM 的防腐结构向导。" ## Swift 专项分析机制 ### 自动引用计数与生命周期探测 (ARC & Memory Leaks) - **闭包循环检测 (Closure Retain Cycle)**: 拦截在闭包中直接通过 `self.method()` 导致的隐式强捕获,强制提醒并重构为 `[weak self]` 或 `[unowned self]`。 - **委托协议生命周期 (Delegate Patterns)**: 防治未被 `@propertyWrapper` 或 `weak` 修饰的 Delegate 指针,导致子控制器锁死父控制器的释放链。 - **大值隐患 (Value Type bloat)**: Swift 中的 `struct` 是按值传递(Copy-on-Write)。检测在集合或大型状态容器中引发隐式全量深拷贝的低效操作。 ### 现代化并发架构 (Structured Concurrency) - **GCD 滥用 (DispatchQueue Hell)**: 找出深层嵌套的 `DispatchQueue.main.asy...

Details

Author
microwind
Repository
microwind/ai-skills
Created
2 months ago
Last Updated
today
Language
Python
License
None

Similar Skills

Semantically similar based on skill content — not just same category

Web & Frontend Solid

apple-engineer-superpowers

Use when writing Swift code for Apple platforms - iOS, macOS, visionOS. Covers Swift 6 concurrency, actors, Sendable, async/await, SwiftUI, MVVM architecture, Metal GPU programming, RealityKit ECS, visionOS scenes, interpolation/animation, advanced collection types, property wrappers, Combine bridging, error handling, testing, and API design patterns.

23 Updated 2 months ago
piemonte
Code & Development Featured

swift-concurrency

Diagnose data races, convert callback-based code to async/await, implement actor isolation patterns, resolve Sendable conformance issues, and guide Swift 6 migration. Use when developers mention: (1) Swift Concurrency, async/await, actors, or tasks, (2) "use Swift Concurrency" or "modern concurrency patterns", (3) migrating to Swift 6, (4) data races or thread safety issues, (5) refactoring closures to async/await, (6) @MainActor, Sendable, or actor isolation, (7) concurrent code architecture or performance optimization, (8) concurrency-related linter warnings (SwiftLint or similar; e.g. async_without_await, Sendable/actor isolation/MainActor lint).

1,509 Updated 3 weeks ago
AvdLee
Code & Development Solid

swift-code-reviewer

Perform thorough code reviews for Swift/SwiftUI code, analyzing code quality, architecture, performance, security, and adherence to Swift 6+ best practices, SwiftUI patterns, navigation architecture, sheet routing, theming, async state, iOS/macOS platform guidelines, and project-specific coding standards from .claude/CLAUDE.md. Use when reviewing code changes, performing quality audits, or providing structured feedback on Swift codebases with all severity levels and positive feedback.

25 Updated 1 weeks ago
Viniciuscarvalho
Testing & QA Solid

swift-testing-expert

Expert guidance for Swift Testing: test structure, #expect/#require macros, traits and tags, parameterized tests, test plans, parallel execution, async waiting patterns, and XCTest migration. Use when writing new Swift tests, modernizing XCTest suites, debugging flaky tests, or improving test quality and maintainability in Apple-platform or Swift server projects.

392 Updated 1 months ago
AvdLee
Web & Frontend Solid

weapp-vite-vue-sfc-best-practices

面向使用 weapp-vite 的小程序项目的 Vue SFC 实践手册,覆盖 `<script setup lang="ts">`、JSON 宏、`definePageMeta`/layout、`defineModel`、`usingComponents`、模板指令兼容、`.weapp-vite` 类型支持文件、受管 `prepare` 工作流,以及和脚手架 `AGENTS.md` / 本地 `dist/docs` 对齐的当前 SFC 约定。

335 Updated today
weapp-vite