axiom-swiftui-debugging

charleswiltgen/axiom · updated Apr 8, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills add https://github.com/charleswiltgen/axiom --skill axiom-swiftui-debugging
0 commentsdiscussion
summary

SwiftUI debugging falls into three categories, each with a different diagnostic approach:

skill.md

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 frustrating"

→ The skill identifies ForEach identity issues and shows how to use stable IDs

When to Use SwiftUI Debugging

Use this skill when

  • ✅ A view isn't updating when you expect it to
  • ✅ Preview crashes or won't load
  • ✅ Layout looks wrong on specific devices
  • ✅ You're tempted to bandaid with @ObservedObject everywhere

Use axiom-xcode-debugging instead when

  • App crashes at runtime (not preview)
  • Build fails completely
  • You need environment diagnostics

Use axiom-swift-concurrency instead when

  • Questions about async/await or MainActor
  • Data race warnings

Debugging Tools

Self._printChanges()

SwiftUI provides a debug-only method to understand why a view's body was called.

Usage in LLDB:

// Set breakpoint in view's body
// In LLDB console:
(lldb) expression Self._printChanges()

Temporary in code (remove before shipping):

var body: some View {
    let _ = Self._printChanges() // Debug only

    Text("Hello")
}

Output interpretation:

MyView: @self changed
  - Means the view value itself changed (parameters passed to view)

MyView: count changed
  - Means @State property "count" triggered the update

MyView: (no output)
  - Body not being called; view not updating at all

⚠️ Important:

  • Prefixed with underscore → May be removed in future releases
  • NEVER submit to App Store with _printChanges calls
  • Performance impact → Use only during debugging

When to use:

  • Need to understand exact trigger for view update
  • Investigating unexpected updates
  • Verifying dependencies after refactoring

Cross-reference: For complex update patterns, use SwiftUI Instrument → see axiom-swiftui-performance skill


View Not Updating Decision Tree

The most common frustration: you changed @State but the view didn't redraw. The root cause is always one of four things.

Step 1: Can You Reproduce in a Minimal Preview?

#Preview {
  YourView()
}

YES → The problem is in your code. Continue to Step 2.

NO → It's likely Xcode state or cache corruption. Skip to Preview Crashes section.

Step 2: Diagnose the Root Cause

Root Cause 1: Struct Mutation

Symptom: You modify a @State value directly, but the view doesn't update.

Why it happens: SwiftUI doesn't see direct mutations on structs. You need to reassign the entire value.

// ❌ WRONG: Direct mutation doesn't trigger update
@State var items: [String] = []

func addItem(_ item: String) {
    items.append(item)  // SwiftUI doesn't see this change
}

// ✅ RIGHT: Reassignment triggers update
@State var items: [String] = []

func addItem(_ item: String) {
    var newItems = items
    newItems.append(item)
    self.items = newItems  // Full reassignment
}

// ✅ ALSO RIGHT: Use a binding
@State var items: [String] = []

var itemsBinding: Binding<[String]> {
    Binding(
        get: { items },
        set: { items = $0 }
    )
}

Fix it: Always reassign the entire struct value, not pieces of it.


Root Cause 2: Lost Binding Identity

Symptom: You pass a binding to a child view, but changes in the child don't update the parent.

Why it happens: You're passing .constant() or creating a new binding each time, breaking the two-way connection.

// ❌ WRONG: Constant binding is read-only
@State var isOn = false

ToggleChild(value: .constant(isOn))  // Changes ignored

// ❌ WRONG: New binding created each render
@State var name = ""

TextField("Name", text: Binding(
    get: { name },
    set: { name = $0 }
))  // New binding object each time parent renders

// ✅ RIGHT: Pass the actual binding
@State var isOn = false

ToggleChild(value: $isOn)

// ✅ RIGHT (iOS 17+): Use @Bindable for @Observable objects
@Observable class Book {
    var title = "Sample"
    var isAvailable = true
}

struct EditView: View {
    @Bindable var book: Book  // Enables $book.title syntax

    var body: some View {
        TextField("Title", text: $book.title)
        Toggle("Available", isOn: $book.isAvailable)
    }
}

// ✅ ALSO RIGHT (iOS 17+): @Bindable as local variable
struct ListView: View {
    @State private var books = [Book(), Book()]

    var body: some View {
        List(books) { book in
            @Bindable var book = book  // Inline binding
            TextField("Title", text: $book.title)
        }
    }
}

// ✅ RIGHT (pre-iOS 17): Create binding once, not in body
@State var name = ""
@State var nameBinding: Binding<String>?

var body: some View {
    if nameBinding == nil {
        nameBinding = Binding(
            get: { name },
            set: { name = $0 }
        )
    }
    return TextField("Name", text: nameBinding!)
}

Fix it: Pass $state directly when possible. For @Observable objects (iOS 17+), use @Bindable. If creating custom bindings (pre-iOS 17), create them in init or cache them, not in body.


Root Cause 3: Accidental View Recreation

Symptom: The view updates, but @State values reset to initial state. You see brief flashes of initial values.

Why it happens: The view got a new identity (removed from a conditional, moved in a container, or the container itself was recreated), causing SwiftUI to treat it as a new view.

// ❌ WRONG: View identity changes when condition flips
@State var count = 
how to use axiom-swiftui-debugging

How to use axiom-swiftui-debugging on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add axiom-swiftui-debugging
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills add https://github.com/charleswiltgen/axiom --skill axiom-swiftui-debugging

The skills CLI fetches axiom-swiftui-debugging from GitHub repository charleswiltgen/axiom and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/axiom-swiftui-debugging

Reload or restart Cursor to activate axiom-swiftui-debugging. Access the skill through slash commands (e.g., /axiom-swiftui-debugging) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

Task Automation & Efficiency

Automate repetitive workflows and reduce manual effort

Example

Generate reports, summarize documents, draft communications

Save 3-5 hours per week on routine tasks

Knowledge Enhancement

Learn new skills, understand complex topics, get expert guidance

Example

Explain concepts, provide examples, suggest learning resources

Accelerate learning and skill development by 2x

Quality Improvement

Enhance output quality through reviews, suggestions, and refinements

Example

Review drafts, suggest improvements, catch errors

Improve work quality by 30-40% with less effort

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client with skill support
  • Clear understanding of task or problem to solve
  • Willingness to iterate and refine outputs

Time Estimate

15-45 minutes depending on use case complexity

Installation Steps

  1. 1.Install skill using provided installation command
  2. 2.Test with simple use case relevant to your work
  3. 3.Evaluate output quality and relevance
  4. 4.Iterate on prompts to improve results
  5. 5.Integrate into regular workflow if valuable

Common Pitfalls

  • Expecting perfect results without iteration
  • Not providing enough context in prompts
  • Using skill for tasks outside its intended scope
  • Accepting outputs without review and validation

Best Practices

✓ Do

  • +Start with clear, specific prompts
  • +Provide relevant context and constraints
  • +Review and refine all outputs before using
  • +Iterate to improve output quality
  • +Document successful prompt patterns

✗ Don't

  • Don't use without understanding skill limitations
  • Don't skip validation of outputs
  • Don't share sensitive information in prompts
  • Don't expect skill to replace human judgment

💡 Pro Tips

  • Be specific about desired format and style
  • Ask for multiple options to choose from
  • Request explanations to understand reasoning
  • Combine AI efficiency with human expertise

When to Use This

✓ Use When

Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.

✗ Avoid When

Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.

Learning Path

  1. 1Familiarize yourself with skill capabilities and limitations
  2. 2Start with low-risk, non-critical tasks
  3. 3Progress to more complex and valuable use cases
  4. 4Build expertise through regular use and experimentation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.557 reviews
  • Chinedu Choi· Dec 28, 2024

    Keeps context tight: axiom-swiftui-debugging is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Hassan Martin· Dec 20, 2024

    Solid pick for teams standardizing on skills: axiom-swiftui-debugging is focused, and the summary matches what you get after install.

  • Ama Sanchez· Dec 20, 2024

    axiom-swiftui-debugging reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Ganesh Mohane· Dec 16, 2024

    axiom-swiftui-debugging has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Dev Rahman· Dec 16, 2024

    Registry listing for axiom-swiftui-debugging matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Mia Shah· Dec 8, 2024

    I recommend axiom-swiftui-debugging for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Diego Thompson· Nov 27, 2024

    Useful defaults in axiom-swiftui-debugging — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Ama Lopez· Nov 27, 2024

    axiom-swiftui-debugging reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Kabir Flores· Nov 19, 2024

    axiom-swiftui-debugging has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Ama Ndlovu· Nov 11, 2024

    Registry listing for axiom-swiftui-debugging matched our evaluation — installs cleanly and behaves as described in the markdown.

showing 1-10 of 57

1 / 6