apple-build-native-uis
4
总安装量
4
周安装量
#49154
全站排名
安装命令
npx skills add https://github.com/pproenca/dot-skills --skill apple-build-native-uis
Agent 安装分布
opencode
4
gemini-cli
4
claude-code
4
codex
4
antigravity
3
windsurf
3
Skill 文档
Apple Build Native UIs Best Practices
Comprehensive SwiftUI interface development guide, extracted from Apple’s official Develop in Swift Tutorials and SwiftUI Concepts. Contains 49 rules across 10 categories, prioritized by impact to guide view composition, layout, styling, state management, and accessibility.
When to Apply
Reference these guidelines when:
- Building new SwiftUI views and screens
- Composing views with stacks, grids, and custom layouts
- Managing state with @State, @Binding, @Observable, and @Environment
- Implementing navigation with NavigationStack, TabView, and sheets
- Adding accessibility, Dynamic Type, and inclusive features
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | View Composition | CRITICAL | comp- |
| 2 | Layout & Sizing | CRITICAL | layout- |
| 3 | Styling & Theming | HIGH | style- |
| 4 | State & Data Flow | HIGH | state- |
| 5 | Navigation & Presentation | HIGH | nav- |
| 6 | Lists & Dynamic Content | MEDIUM-HIGH | list- |
| 7 | User Input & Interaction | MEDIUM-HIGH | input- |
| 8 | Accessibility & Adaptivity | MEDIUM | access- |
| 9 | Testing & Debugging | MEDIUM | test- |
| 10 | App Polish & Refinement | LOW | polish- |
Quick Reference
1. View Composition (CRITICAL)
comp-body-some-view– Return some View from body propertycomp-custom-view-properties– Use properties to make views configurablecomp-extract-subviews– Extract subviews to reduce body complexitycomp-modifier-order– Apply modifiers in correct ordercomp-prefer-composition– Prefer composition over inheritance for viewscomp-preview-macro– Use #Preview for live development feedbackcomp-view-builder– Use @ViewBuilder for conditional view content
2. Layout & Sizing (CRITICAL)
layout-frame-sizing– Use frame() for explicit size constraintslayout-grid-for-tables– Use Grid for aligned tabular layoutslayout-lazy-grids– Use LazyVGrid for scrollable grid layoutslayout-spacer-for-distribution– Use Spacer to push views apartlayout-stack-alignment-spacing– Configure stack alignment and spacinglayout-stacks-over-position– Use stacks instead of manual positioninglayout-zstack-layering– Use ZStack for layered view composition
3. Styling & Theming (HIGH)
style-font-hierarchy– Use semantic font styles for typographystyle-foreground-over-color– Use foregroundStyle over deprecated foregroundColorstyle-gradients– Apply gradients for visual depthstyle-sf-symbols– Use SF Symbols for platform-consistent iconsstyle-system-colors– Use system colors for automatic dark mode
4. State & Data Flow (HIGH)
state-bindable-for-observable– Use @Bindable to create bindings from observable objectsstate-binding-for-children– Use @Binding for two-way data flow to child viewsstate-environment-for-shared– Use @Environment for system and shared valuesstate-observable-for-models– Use @Observable for shared model classesstate-private-state– Mark @State properties as privatestate-state-for-local– Use @State for view-local value types
5. Navigation & Presentation (HIGH)
nav-navigation-stack– Use NavigationStack for hierarchical navigationnav-programmatic-path– Manage navigation state with path bindingnav-sheets-for-modal– Use sheets for modal presentationnav-tabview-sections– Use TabView for top-level app sectionsnav-toolbar-actions– Place actions in toolbar for consistent placement
6. Lists & Dynamic Content (MEDIUM-HIGH)
list-foreach-dynamic– Use ForEach for dynamic content in containerslist-identifiable-data– Use List with Identifiable datalist-searchable– Use searchable for built-in searchlist-swipe-actions– Add swipe actions for contextual operations
7. User Input & Interaction (MEDIUM-HIGH)
input-button-actions– Use Button with action closuresinput-picker-selection– Use Picker for single-value selectioninput-textfield-binding– Use TextField with binding for text inputinput-toggle-forms– Use Toggle and Form for settings interfaces
8. Accessibility & Adaptivity (MEDIUM)
access-accessibility-labels– Add accessibility labels to interactive elementsaccess-dynamic-type– Support Dynamic Type for all textaccess-scaled-metric– Use @ScaledMetric for size-adaptive valuesaccess-view-that-fits– Use ViewThatFits for adaptive layouts
9. Testing & Debugging (MEDIUM)
test-breakpoints– Use breakpoints to debug runtime issuestest-preview-sample-data– Use Preview with sample data for visual testingtest-swift-testing– Write tests with Swift Testing framework
10. App Polish & Refinement (LOW)
polish-inclusive-features– Add inclusive features for broader reachpolish-transition-effects– Apply transition effects for view insertion and removalpolish-with-animation– Use withAnimation for state-driven transitions
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions – Category structure and impact levels
- Rule template – Template for adding new rules
Full Compiled Document
For a complete compiled guide with all rules in a single document, see AGENTS.md.
Reference Files
| File | Description |
|---|---|
| AGENTS.md | Complete compiled guide with all rules |
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |