swift-ios
SwiftUI and iOS engineering standards: state and data flow, view structure, navigation, layout, modern and deprecated APIs, accessibility, animation, performance, Swift concurrency, SwiftData and Liquid Glass. TRIGGER — load BEFORE writing or editing Swift, not after: any .swift, Package.swift, .xcodeproj or .xcworkspace file is touched, SwiftUI, iOS, iPadOS, Xcode or Swift concurrency is named, or the working directory holds an Xcode project or Swift package and the task is implementation, refactor, review or test-writing. Plain requests in an iOS repo ("add a screen", "fix this view", "why does this list flicker", "make this async") count; the user will not say "SwiftUI best practices". Load it for test files too, alongside swift-testing, and even when another skill (tdd, simplify) is active. SKIP only when no Swift file is involved and Swift is not named.
- License 许可
- MIT
- 最近更新
- 2026-11-11
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- swift-ios
- license
- MIT
- metadata
- { "sources": "Merged and rewritten from MIT-licensed skills: twostraws/SwiftUI-Agent-Skill@1eac100, AvdLee/SwiftUI-Agent-Skill@204dba7, twostraws/Swift-Concurrency-Agent-Skill@bee3f69, AvdLee/Swift-Concurrency-Agent-Skill@d577081, twostraws/SwiftData-Agent-Skill@8051f17, Dimillian/Skills@05ba982.\n" }
- description
- SwiftUI and iOS engineering standards: state and data flow, view structure, navigation, layout, modern and deprecated APIs, accessibility, animation, performance, Swift concurrency, SwiftData and Liquid Glass. TRIGGER — load BEFORE writing or editing Swift, not after: any .swift, Package.swift, .xcodeproj or .xcworkspace file is touched, SwiftUI, iOS, iPadOS, Xcode or Swift concurrency is named, or the working directory holds an Xcode project or Swift package and the task is implementation, refactor, review or test-writing. Plain requests in an iOS repo ("add a screen", "fix this view", "why does this list flicker", "make this async") count; the user will not say "SwiftUI best practices". Load it for test files too, alongside swift-testing, and even when another skill (tdd, simplify) is active. SKIP only when no Swift file is involved and Swift is not named.
- allowed-tools
- Read, Edit, Write, Glob, Grep, Bash(xcodebuild:*), Bash(swift:*), Bash(xcrun:*), Bash(git:*), Agent
02 资源文件 23
- 参考文档evals/evals.json11.4 KB
- 其他evals/fixtures/concurrency-error/Package.swift168 B
- 其他evals/fixtures/concurrency-error/Sources/Photos/GalleryModel.swift451 B
- 其他evals/fixtures/concurrency-error/Sources/Photos/ThumbnailCache.swift496 B
- 其他evals/fixtures/deprecated-list/Package.swift166 B
- 其他evals/fixtures/deprecated-list/Sources/Inbox/InboxView.swift1.0 KB
- 其他evals/fixtures/deprecated-list/Sources/Inbox/MessageDetail.swift296 B
- 其他evals/fixtures/perf-review/Package.swift264 B
- 其他evals/fixtures/perf-review/Sources/Feed/FeedView.swift1.4 KB
- 其他evals/fixtures/state-bug/Package.swift166 B
- 其他evals/fixtures/state-bug/Sources/Notes/NotesListView.swift1.0 KB
- 其他evals/fixtures/state-bug/Sources/Notes/NotesStore.swift396 B
- 参考文档references/accessibility-and-text.md9.5 KB
- 参考文档references/animation.md7.9 KB
- 参考文档references/concurrency.md20.9 KB
- 参考文档references/layout.md17.2 KB
- 参考文档references/liquid-glass.md6.7 KB
- 参考文档references/modern-api.md13.5 KB
- 参考文档references/navigation.md11.1 KB
- 参考文档references/performance.md11.0 KB
- 参考文档references/platform-facts.md3.2 KB
- 参考文档references/swiftdata.md8.5 KB
- 参考文档references/views-and-state.md16.2 KB
03 SKILL.md 正文
Swift iOS
House rules for SwiftUI apps on iOS and iPadOS. The rules below apply to every change; the references hold the detail. Read only the references the task touches.
Before you write
- Read the project's settings. Deployment target (
IPHONEOS_DEPLOYMENT_TARGETin the.pbxproj,platforms:inPackage.swift), Swift language mode, default actor isolation (SWIFT_DEFAULT_ACTOR_ISOLATION, or.defaultIsolation(MainActor.self)inswiftSettings) and strict-concurrency level. Advice that depends on any of these is wrong until you know them. Keep the existing target; don't raise it to use an API. - Read the neighbouring code. Its architecture, folder layout and naming win over this skill's defaults. If the codebase uses view models, add view models.
- Check dated facts in
references/platform-facts.mdbefore calling an API speculative or new. That file is the only place this skill names OS, Xcode or Swift versions as current.
Operating rules
- Architecture: MV. Views own UI state with
@State; app logic lives in@Observablemodels and services injected through the environment or initialisers. Don't add a per-screen view model unless one of the cases inreferences/views-and-state.md§ "When a view model is justified" applies, or the codebase already uses them. @MainActorfollows the project's isolation. In a MainActor-default target, don't annotate. Otherwise give UI-state@Observablemodels@MainActorand leave non-UI services (networking, parsing, persistence) unisolated. Never add@MainActor,@unchecked Sendable,nonisolated(unsafe)or@preconcurrencyjust to silence a diagnostic; find the isolation bug (references/concurrency.md).- Deprecated APIs: in code the task touches, replace hard-deprecated APIs and flag
soft-deprecated ones (
deprecated: 100000.0, so the build stays quiet) without rewriting them. Never introduce either in new code. Don't scan or flag views the task doesn't touch (references/modern-api.mdhas the hard/soft table). - Availability: gate any API newer than the deployment target with
#availableand give it a working fallback. A runtime check doesn't help if the SDK lacks the symbol, so match the project's Xcode too. - Liquid Glass: keep the glass stock components give you. Don't fight it with opaque toolbar
or tab-bar backgrounds. Don't hand-roll
glassEffector custom glass unless the user asks (references/liquid-glass.md). - Performance: apply the routine rules in
references/performance.mdalways. Restructure for performance (splitting observation, narrowing dependencies) only for a diagnosed problem or a requested deep performance review. - Prefer SwiftUI to UIKit unless bridging is the only way. Don't add a third-party dependency without asking.
- One primary type per file. Group folders by feature.
Correctness checklist
Treat a violation as a bug, in your own code and in code you review:
- [ ]
@Stateand@FocusStateareprivate; parent-owned inputs are not copied into@State - [ ]
@ObservableoverObservableObjectfor new code;@Stateowns it,@Bindablefor injected models that need bindings - [ ]
@Bindingonly where the child writes parent state - [ ] No
Binding(get:set:)inbody; bind directly and react withonChange - [ ]
ForEachidentity is stable: never.indicesor\.selfon mutable values; one view per element - [ ] Tappable things are
Buttons with a text label (useButton("Add", systemImage:)for icon buttons), notonTapGesture - [ ]
.animation(_:value:), never withoutvalue:; new code usesforegroundStyle, notforegroundColor - [ ] Environment
@Entrydefaults are stable values, neverModel(),Date()orUUID() - [ ] No GCD in new code;
Task.sleep(for:), not nanoseconds - [ ]
ModelContextand@Modelinstances never cross actors; passPersistentIdentifier - [ ] Version-specific APIs are gated with
#availableand have fallbacks - [ ] Previews use in-memory, self-contained data; no network or live store
Where to look
| If you're working on… | Read |
|---|---|
Property wrappers, data flow, @Observable models, environment, view decomposition, modifier order, async loading state, previews |
references/views-and-state.md |
NavigationStack/NavigationSplitView, routes, sheets, alerts, dialogs, tabs, toolbars, search, deep links |
references/navigation.md |
| Stacks, grids, lists, forms, scroll views, safe areas, size classes, iPad multitasking, foldables | references/layout.md |
| Whether an API is deprecated, its replacement, modern Swift idioms | references/modern-api.md |
| VoiceOver, Dynamic Type, Reduce Motion, localisation, text formatting, HIG, theming, haptics | references/accessibility-and-text.md |
| Implicit/explicit animation, transitions, matched geometry, phase and keyframe animation | references/animation.md |
| Slow lists, janky scrolling, excess body evaluations, image decoding, a perf review | references/performance.md |
async/await, actors, Task, cancellation, Sendable errors, Swift 6 migration, bridging callbacks |
references/concurrency.md |
@Model, @Query, predicates, relationships, indexes, CloudKit sync, ModelActor |
references/swiftdata.md |
Toolbars, tab bars or custom controls on iOS 26+, any glassEffect request |
references/liquid-glass.md |
| Current OS, Xcode and Swift versions, new devices | references/platform-facts.md |
| Writing or reviewing tests | the swift-testing skill, if installed, alongside this one |
Not covered, so don't assume this skill has an answer: macOS scenes, windows and views; Swift Charts; WebKit; document-based apps; styled text editing; focus management; Instruments trace recording and analysis; Core Data.
Feature work vs review
During feature work or a bug fix, make the change and stop. Don't rewrite unrelated code. If the code you edited uses soft-deprecated APIs, offer the migration in one line at the end.
When asked to review, report only real problems, grouped by file:
- The file and line(s).
- The rule broken, named in one line (e.g. "Use
foregroundStyle()instead offoregroundColor()"). - A short before/after fix.
Skip files with no findings. End with a prioritised summary, most impactful first, each item tagged with its area and severity, e.g. Accessibility (high): the add button has no label. For a whole-app review, pick focus areas first and work through them one at a time.
04 同仓库更多 Skills
obsidian-develop
Build, prototype, extend, debug and review Obsidian community plugins against a live vault: inspect the running app's UI, DOM, console and plugin state, prototype in the runtime, then verify each change with a build, reload and check loop. Use whenever the user is working on an Obsidian plugin, even when they just say "add a command", "make a sidebar view", "my settings tab is blank", "why isn't my view updating" or "get this ready for the community directory"; when they ask about the plugin API (obsidian.d.ts, Workspace, leaves, Vault, MetadataCache, FileManager, views, modals, settings tabs, CodeMirror 6 editor extensions, markdown post-processors, events); or when they want a running Obsidian instance's DOM, CSS, console or plugins inspected. Not for general note-taking, Obsidian Markdown syntax, themes without a plugin, or managing vault content (use ingest, to-vault or vault-recall for those).
vault-recall
Answer the user's conceptual or technical question using their Obsidian vault as well as general knowledge. Use when the user asks a question (not a task) whose topic appears in the vault MOC digest from session start. Not for task instructions, not mid-task, and not for writing to the vault (that is to-vault).
ingest
Ingest one external source (an article, course lesson, doc, PDF or URL) into the user's Obsidian vault: save the original to raw/, then build wiki/ pages per the vault's § Ingest. Use when the user types /ingest, or says "ingest this", "add this source to my wiki", "put this article/lesson in the vault as a wiki page". Works from any repo. Routing rule: someone else's words go to wiki/ (this skill); the user's own learnings and decisions go to notes/ (/to-vault).
to-tickets
Breaks a source into independently-grabbable GitHub tickets. For a code feature the source is the plan (`docs/plans/<feature>.md`, from /to-plan) and every new or changed symbol lands in exactly one ticket, its signatures copied into the ticket body; a non-code feature is cut from the PRD's slices. Cuts tickets for one feature per run. If a code feature has no approved plan, offers /to-plan instead of cutting from prose. In a repo that runs command-centre, also emits `[[task]]` blocks into its config; in a plain treepad repo, emits a Batch Manifest instead so the tickets materialise as stacked worktrees.
to-seams
Records an agreed-but-unlanded cross-repo interface as a seam: the file a consumer's agent gets pasted into its prompt as ground truth, plus the `[[seam]]` block command-centre reads for the retirement pointer. Use when two repos need to build against an interface neither has landed yet — "record a seam for X", "we agreed on this schema, seam it", "add a seam so Y can build against Z's new field". Halts for approval before writing either file.
to-roadmap
Prioritises settled features into a Now / Next / Later kanban board, rendered as a self-contained ./ideas/roadmap.html. Each card is a feature, not a ticket — one card later becomes several tickets via /to-prd -> /to-plan -> /to-tickets. Boards the features in ./docs/approach.md, or the "## Accepted ideas" in ./ideas/CONTEXT.md when there is no approach doc. The approach doc is settled truth: this assigns tiers and reasons about ordering, it never re-litigates what was decided.