🛠️ SwiftuiUIパターン集
iPhoneアプリなどの画面を効率的かつ使いやすく設計
📺 まず動画で見る(YouTube)
▶ 【衝撃】最強のAIエージェント「Claude Code」の最新機能・使い方・プログラミングをAIで効率化する超実践術を解説! ↗
※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。
📜 元の英語説明(参考)
Apply proven SwiftUI UI patterns for navigation, sheets, async state, and reusable screens.
🇯🇵 日本人クリエイター向け解説
iPhoneアプリなどの画面を効率的かつ使いやすく設計
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-17
- 同梱ファイル
- 31
💬 こう話しかけるだけ — サンプルプロンプト
- › Swiftui UI Patterns を使って、最小構成のサンプルコードを示して
- › Swiftui UI Patterns の主な使い方と注意点を教えて
- › Swiftui UI Patterns を既存プロジェクトに組み込む方法を教えて
これをClaude Code に貼るだけで、このSkillが自動発動します。
📖 Claude が読む原文 SKILL.md(中身を展開)
この本文は AI(Claude)が読むための原文(英語または中国語)です。日本語訳は順次追加中。
SwiftUI UI Patterns
Quick start
When to Use
- When creating or refactoring SwiftUI screens, flows, or reusable UI components.
- When you need guidance on navigation, sheets, async state, previews, or component patterns.
Choose a track based on your goal:
Existing project
- Identify the feature or screen and the primary interaction model (list, detail, editor, settings, tabbed).
- Find a nearby example in the repo with
rg "TabView\("or similar, then read the closest SwiftUI view. - Apply local conventions: prefer SwiftUI-native state, keep state local when possible, and use environment injection for shared dependencies.
- Choose the relevant component reference from
references/components-index.mdand follow its guidance. - If the interaction reveals secondary content by dragging or scrolling the primary content away, read
references/scroll-reveal.mdbefore implementing gestures manually. - Build the view with small, focused subviews and SwiftUI-native data flow.
New project scaffolding
- Start with
references/app-wiring.mdto wire TabView + NavigationStack + sheets. - Add a minimal
AppTabandRouterPathbased on the provided skeletons. - Choose the next component reference based on the UI you need first (TabView, NavigationStack, Sheets).
- Expand the route and sheet enums as new screens are added.
General rules to follow
- Use modern SwiftUI state (
@State,@Binding,@Observable,@Environment) and avoid unnecessary view models. - If the deployment target includes iOS 16 or earlier and cannot use the Observation API introduced in iOS 17, fall back to
ObservableObjectwith@StateObjectfor root ownership,@ObservedObjectfor injected observation, and@EnvironmentObjectonly for truly shared app-level state. - Prefer composition; keep views small and focused.
- Use async/await with
.taskand explicit loading/error states. For restart, cancellation, and debouncing guidance, readreferences/async-state.md. - Keep shared app services in
@Environment, but prefer explicit initializer injection for feature-local dependencies and models. For root wiring patterns, readreferences/app-wiring.md. - Prefer the newest SwiftUI API that fits the deployment target and call out the minimum OS whenever a pattern depends on it.
- Maintain existing legacy patterns only when editing legacy files.
- Follow the project's formatter and style guide.
- Sheets: Prefer
.sheet(item:)over.sheet(isPresented:)when state represents a selected model. Avoidif letinside a sheet body. Sheets should own their actions and calldismiss()internally instead of forwardingonCancel/onConfirmclosures. - Scroll-driven reveals: Prefer deriving a normalized progress value from scroll offset and driving the visual state from that single source of truth. Avoid parallel gesture state machines unless scroll alone cannot express the interaction.
State ownership summary
Use the narrowest state tool that matches the ownership model:
| Scenario | Preferred pattern |
|---|---|
| Local UI state owned by one view | @State |
| Child mutates parent-owned value state | @Binding |
| Root-owned reference model on iOS 17+ | @State with an @Observable type |
Child reads or mutates an injected @Observable model on iOS 17+ |
Pass it explicitly as a stored property |
| Shared app service or configuration | @Environment(Type.self) |
| Legacy reference model on iOS 16 and earlier | @StateObject at the root, @ObservedObject when injected |
Choose the ownership location first, then pick the wrapper. Do not introduce a reference model when plain value state is enough.
Cross-cutting references
references/navigationstack.md: navigation ownership, per-tab history, and enum routing.references/sheets.md: centralized modal presentation and enum-driven sheets.references/deeplinks.md: URL handling and routing external links into app destinations.references/app-wiring.md: root dependency graph, environment usage, and app shell wiring.references/async-state.md:.task,.task(id:), cancellation, debouncing, and async UI state.references/previews.md:#Preview, fixtures, mock environments, and isolated preview setup.references/performance.md: stable identity, observation scope, lazy containers, and render-cost guardrails.
Anti-patterns
- Giant views that mix layout, business logic, networking, routing, and formatting in one file.
- Multiple boolean flags for mutually exclusive sheets, alerts, or navigation destinations.
- Live service calls directly inside
body-driven code paths instead of view lifecycle hooks or injected models/services. - Reaching for
AnyViewto work around type mismatches that should be solved with better composition. - Defaulting every shared dependency to
@EnvironmentObjector a global router without a clear ownership reason.
Workflow for a new SwiftUI view
- Define the view's state, ownership location, and minimum OS assumptions before writing UI code.
- Identify which dependencies belong in
@Environmentand which should stay as explicit initializer inputs. - Sketch the view hierarchy, routing model, and presentation points; extract repeated parts into subviews. For complex navigation, read
references/navigationstack.md,references/sheets.md, orreferences/deeplinks.md. Build and verify no compiler errors before proceeding. - Implement async loading with
.taskor.task(id:), plus explicit loading and error states when needed. Readreferences/async-state.mdwhen the work depends on changing inputs or cancellation. - Add previews for the primary and secondary states, then add accessibility labels or identifiers when the UI is interactive. Read
references/previews.mdwhen the view needs fixtures or injected mock dependencies. - Validate with a build: confirm no compiler errors, check that previews render without crashing, ensure state changes propagate correctly, and sanity-check that list identity and observation scope will not cause avoidable re-renders. Read
references/performance.mdif the screen is large, scroll-heavy, or frequently updated. For common SwiftUI compilation errors — missing@Stateannotations, ambiguousViewBuilderclosures, or mismatched generic types — resolve them before updating callsites. If the build fails: read the error message carefully, fix the identified issue, then rebuild before proceeding to the next step. If a preview crashes, isolate the offending subview, confirm its state initialisation is valid, and re-run the preview before continuing.
Component references
Use references/components-index.md as the entry point. Each component reference should include:
- Intent and best-fit scenarios.
- Minimal usage pattern with local conventions.
- Pitfalls and performance notes.
- Paths to existing examples in the current repo.
Adding a new component reference
- Create
references/<component>.md. - Keep it short and actionable; link to concrete files in the current repo.
- Update
references/components-index.mdwith the new entry.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
同梱ファイル
※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。
- 📄 SKILL.md (7,680 bytes)
- 📎 references/app-wiring.md (6,637 bytes)
- 📎 references/async-state.md (2,833 bytes)
- 📎 references/components-index.md (4,303 bytes)
- 📎 references/controls.md (1,682 bytes)
- 📎 references/deeplinks.md (1,703 bytes)
- 📎 references/focus.md (2,390 bytes)
- 📎 references/form.md (3,062 bytes)
- 📎 references/grids.md (1,851 bytes)
- 📎 references/haptics.md (2,049 bytes)
- 📎 references/input-toolbar.md (1,451 bytes)
- 📎 references/lightweight-clients.md (2,524 bytes)
- 📎 references/list.md (2,732 bytes)
- 📎 references/loading-placeholders.md (1,274 bytes)
- 📎 references/macos-settings.md (1,997 bytes)
- 📎 references/matched-transitions.md (1,674 bytes)
- 📎 references/media.md (2,040 bytes)
- 📎 references/menu-bar.md (2,236 bytes)
- 📎 references/navigationstack.md (4,343 bytes)
- 📎 references/overlay.md (1,238 bytes)
- 📎 references/performance.md (1,990 bytes)
- 📎 references/previews.md (1,688 bytes)
- 📎 references/scroll-reveal.md (5,299 bytes)
- 📎 references/scrollview.md (2,364 bytes)
- 📎 references/searchable.md (1,727 bytes)
- 📎 references/sheets.md (4,272 bytes)
- 📎 references/split-views.md (2,027 bytes)
- 📎 references/tabview.md (3,486 bytes)
- 📎 references/theming.md (1,776 bytes)
- 📎 references/title-menus.md (2,115 bytes)
- 📎 references/top-bar.md (1,359 bytes)