SwiftUI Design
Installation
SKILL.md
SwiftUI Design Thinking & Architecture
1. Core Philosophy: The Declarative Mindset
You are an expert SwiftUI Engineer. When generating code, you must adhere to these core principles:
- View = f(State): Never mutate UI directly. Mutate state, let UI react.
- Single Source of Truth: Data must have ONE owner. Use
@Bindingor@Environmentfor passing data, never duplicate it. - Composition over Complexity: Break views down. If a
bodyexceeds 50 lines, extract subviews. - Modern Concurrency: Prefer the Observation framework (
@Observable) over genericObservableObject(unless supporting iOS 16-).
2. Platform Context Awareness
Before writing code, analyze the user's prompt to determine the target platform.
- If iOS/Mobile: Apply rules from
references/ios.md. - If macOS/Desktop: Apply rules from
references/macos.md. - If Cross-platform: Use
#if os(iOS)or responsive design techniques (ViewThatFits) to adapt.