swiftui-debugging

Diagnose SwiftUI performance issues using _printChanges() and Instruments templates.

27|5|Updated Apr 18, 2026
One-click install
npx skills add https://github.com/bocan/bocan-music --skill swiftui-debugging-bocan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swiftui-debugging
Source: https://github.com/bocan/bocan-music/tree/main/.claude/skills/performance/swiftui-debugging
Command: npx skills add https://github.com/bocan/bocan-music --skill swiftui-debugging-bocan

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill eliminates the frustration of slow, janky SwiftUI views caused by unnecessary re-renders, poor view identity management, incorrect lazy loading usage, and common performance anti-patterns that degrade the user experience of macOS and iOS apps.

Core Features & Use Cases

  • Re-render Diagnosis: Identify exactly which dependencies trigger unnecessary view body re-evaluations using the Self._printChanges() method and fix over-observation with @Observable versus ObservableObject.
  • Scrolling Performance: Resolve stutters and hangs in lists and grids by correcting eager versus lazy container usage, fixing image loading, and eliminating layout bottlenecks.
  • View Identity Fixes: Resolve unexpected state loss, broken animations, and repeated onAppear calls caused by unstable .id() values and incorrect conditional view branching.
  • Use Case: For example, if your music app's song library list stutters when scrolling through 1000+ tracks, this skill guides you to switch from an eager VStack to a LazyVStack and fix unstable row identifiers to restore smooth 120fps scrolling.

Quick Start

Use the swiftui-debugging skill to identify why your SwiftUI library view re-renders excessively when the playback queue updates and apply the recommended fixes to reduce unnecessary body evaluations.

Frequently Asked Questions about swiftui-debugging

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does my SwiftUI view re-render excessively and how do I diagnose the trigger?

SwiftUI view re-renders occur when observed state changes trigger unnecessary body evaluations; you can diagnose the exact dependency triggers using the Self._printChanges() method to identify and fix over-observation issues.

How do I fix janky scrolling in SwiftUI lists with 1000+ items?

To fix janky scrolling in SwiftUI lists, switch from eager containers like VStack to LazyVStack, correct image loading bottlenecks, and stabilize row identifiers to restore smooth scrolling performance.

What causes unexpected state loss and broken animations in SwiftUI?

Unexpected state loss and broken animations in SwiftUI are caused by unstable .id() values and incorrect conditional view branching, which compromise view identity and prevent the hierarchy from tracking state correctly.

Does the @Observable macro improve SwiftUI performance compared to ObservableObject?

The @Observable macro improves SwiftUI performance by enabling per-property observation, preventing unnecessary view body re-evaluations that typically occur when using the older ObservableObject protocol.

Can I use Instruments to debug high CPU usage from SwiftUI view hierarchies?

You can debug high CPU usage from SwiftUI view hierarchies using the Instruments SwiftUI templates to profile body evaluations and identify layout bottlenecks in macOS and iOS apps.

When should I not use lazy loading in SwiftUI containers?

You should avoid lazy loading in SwiftUI containers when evaluating small lists where the overhead of lazy view instantiation outweighs the performance benefit, potentially causing unexpected view identity issues.