Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

axiom-swiftui-debugging-diag

FreeNo executable scriptsNot checked

Use when SwiftUI view debugging requires systematic investigation - view updates not working after basic troubleshooting, intermittent UI issues, complex…

ComeOnOliverby ComeOnOliver★ 67 GitHub stars

About this skill

SwiftUI Debugging Diagnostics

When to Use This Diagnostic Skill

Use this skill when:

  • Basic troubleshooting failed — Applied axiom-swiftui-debugging skill patterns but issue persists
  • Self._printChanges() shows unexpected patterns — View updating when it shouldn't, or not updating when it should
  • Intermittent issues — Works sometimes, fails other times ("heisenbug")
  • Complex dependency chains — Need to trace data flow through multiple views/models
  • Performance investigation — Views updating too often or taking too long
  • Preview mysteries — Crashes or failures that aren't immediately obvious

FORBIDDEN Actions

Under pressure, you'll be tempted to shortcuts that hide problems instead of diagnosing them. NEVER do these:

❌ Guessing with random @State/@Observable changes

  • "Let me try adding @Observable here and see if it works"
  • "Maybe if I change this to @StateObject it'll fix it"

❌ Adding .id(UUID()) to force updates

  • Creates new view identity every render
  • Destroys state preservation
  • Masks root cause

❌ Using ObservableObject when @Observable would work (iOS 17+)

  • Adds unnecessary complexity
  • Miss out on automatic dependency tracking

❌ Ignoring intermittent issues ("works sometimes")

  • "I'll just merge and hope it doesn't happen in production"
  • Intermittent = systematic bug, not randomness

❌ Shipping without understanding

  • "The fix works, I don't know why"
  • Production is too expensive for trial-and-error

Mandatory First Steps

Before diving into diagnostic patterns, establish baseline environment:

# 1. Verify Instruments setup
xcodebuild -version  # Must be Xcode 26+ for SwiftUI Instrument

# 2. Build in Release mode for profiling
xcodebuild build -scheme YourScheme -configuration Release

# 3. Clear derived data if investigating preview issues
rm -rf ~/Library/Developer/Xcode/DerivedData

Time cost: 5 minutes Why: Wrong Xcode version or Debug mode produces misleading profiling data


Diagnostic Decision Tree

SwiftUI view issue after basic troubleshooting?
│
├─ View not updating?
│  ├─ Basic check: Add Self._printChanges() temporarily
│  │  ├─ Shows "@self changed" → View value changed
│  │  │  └─ Pattern D1: Analyze what caused view recreation
│  │  ├─ Shows specific state property → That state triggered update
│  │  │  └─ Verify: Should that state trigger update?
│  │  └─ Nothing logged → Body not being called at all
│  │     └─ Pattern D3: View Identity Investigation
│  └─ Advanced: Use SwiftUI Instrument
│     └─ Pattern D2: SwiftUI Instrument Investigation
│
├─ View updating too often?
│  ├─ Pattern D1: Self._printChanges() Analysis
│  │  └─ Identify unnecessary state dependencies
│  └─ Pattern D2: SwiftUI Instrument → Cause & Effect Graph
│     └─ Trace data flow, find broad dependencies
│
├─ Intermittent issues (works sometimes)?
│  ├─ Pattern D3: View Identity Investigation
│  │  └─ Check: Does identity change unexpectedly?
│  ├─ Pattern D4: Environment Dependency Check
│  │  └─ Check: Environment values changing frequently?
│  └─ Reproduce in preview 30+ times
│     └─ If can't reproduce: Likely timing/race condition
│
└─ Preview crashes (after basic fixes)?
    ├─ Pattern D5: Preview Diagnostics (Xcode 26)
    │  └─ Check diagnostics button, crash logs
    └─ If still fails: Pattern D2 (profile preview build)

Diagnostic Patterns

Pattern D1: Self._printChanges() Analysis

Time cost: 5 minutes

Symptom: Need to understand exactly why view body runs

When to use:

  • View updating more often than expected
  • View not updating when it should
  • Verifying dependencies after refactoring

Technique:

struct MyView: View {
    @State private var count = 0
    @Environment(AppModel.self) private var model

    var body: some View {
        let _ = Self._printChanges()  // Add temporarily

        VStack {
            Text("Count: \(count)")
            Text("Model value: \(model.value)")
        }
    }
}

Output interpretation:

# Scenario 1: View parameter changed
MyView: @self changed
→ Parent passed new MyView instance
→ Check parent code - what triggered recreation?

# Scenario 2: State property changed
MyView: count changed
→ Local @State triggered update
→ Expected if you modified count

# Scenario 3: Environment property changed
MyView: @self changed  # Environment is part of @self
→ Environment value changed (color scheme, locale, custom value)
→ Pattern D4: Check environment dependencies

# Scenario 4: Nothing logged
→ Body not being called
→ Pattern D3: View identity investigation

Common discoveries:

  1. "@self changed" when you don't expect

    • Parent recreating view unnecessarily
    • Check parent's state management
  2. Property shows changed but you didn't change it

    • Indirect dependency (reading from object that changed)
    • Pattern D2: Use Instruments to trace
  3. *Multiple properties changing together

Full SKILL.md on GitHub

Install axiom-swiftui-debugging-diag in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

FAQ

What does the axiom-swiftui-debugging-diag skill do?

Use when SwiftUI view debugging requires systematic investigation - view updates not working after basic troubleshooting, intermittent UI issues, complex state dependencies, or when Self._printChanges() shows unexpected update patterns - systematic diagnostic workflows with Instruments integration

How do I install the axiom-swiftui-debugging-diag skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the axiom-swiftui-debugging-diag skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare axiom-swiftui-debugging-diag with