Use when debugging SwiftUI view updates, preview crashes, or layout issues - diagnostic decision trees to identify root causes quickly and avoid misdiagnosis under pressure
View on GitHubSelect agents to install to:
npx add-skill https://github.com/CharlesWiltgen/Axiom/blob/main/.claude-plugin/plugins/axiom/skills/axiom-swiftui-debugging/SKILL.md -a claude-code --skill axiom-swiftui-debuggingInstallation paths:
.claude/skills/axiom-swiftui-debugging/# SwiftUI Debugging ## Overview SwiftUI debugging falls into three categories, each with a different diagnostic approach: 1. **View Not Updating** – You changed something but the view didn't redraw. Decision tree to identify whether it's struct mutation, lost binding identity, accidental view recreation, or missing observer pattern. 2. **Preview Crashes** – Your preview won't compile or crashes immediately. Decision tree to distinguish between missing dependencies, state initialization failures, and Xcode cache corruption. 3. **Layout Issues** – Views appearing in wrong positions, wrong sizes, overlapping unexpectedly. Quick reference patterns for common scenarios. **Core principle**: Start with observable symptoms, test systematically, eliminate causes one by one. Don't guess. **Requires**: Xcode 26+, iOS 17+ (iOS 14-16 patterns still valid, see notes) **Related skills**: `axiom-xcode-debugging` (cache corruption diagnosis), `axiom-swift-concurrency` (observer patterns), `axiom-swiftui-performance` (profiling with Instruments), `axiom-swiftui-layout` (adaptive layout patterns) ## Example Prompts These are real questions developers ask that this skill is designed to answer: #### 1. "My list item doesn't update when I tap the favorite button, even though the data changed" → The skill walks through the decision tree to identify struct mutation vs lost binding vs missing observer #### 2. "Preview crashes with 'Cannot find AppModel in scope' but it compiles fine" → The skill shows how to provide missing dependencies with `.environment()` or `.environmentObject()` #### 3. "My counter resets to 0 every time I toggle a boolean, why?" → The skill identifies accidental view recreation from conditionals and shows `.opacity()` fix #### 4. "I'm using @Observable but the view still doesn't update when I change the property" → The skill explains when to use @State vs plain properties with @Observable objects #### 5. "Text field loses focus when I start typing, very fr