swiftui-debugging

Solid

Use when debugging SwiftUI issues in this macOS app — views not updating, layout problems, unnecessary re-renders, state ownership bugs, Preview crashes, or NSHostingView/NSPanel quirks. Covers both general SwiftUI debugging and macOS-specific patterns.

Code & Development 150 stars 21 forks Updated 5 days ago MIT

Install

View on GitHub

Quality Score: 84/100

Stars 20%
73
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# SwiftUI Debugging ## Overview Systematic approaches for debugging SwiftUI issues in macOS apps. Covers view updates, state ownership, performance, layout, and macOS-specific quirks with NSHostingView and NSPanel. ## Logging in macOS Apps `print()` and `NSLog()` are invisible when launching macOS apps from CLI or Finder (menubar-only apps have no console). Always use file-based logging: ```swift func debugLog(_ message: String) { let entry = "\(Date()) \(message)\n" let url = URL(fileURLWithPath: "/tmp/debug.log") if let handle = try? FileHandle(forWritingTo: url) { handle.seekToEndOfFile() handle.write(entry.data(using: .utf8)!) handle.closeFile() } else { try? entry.write(to: url, atomically: true, encoding: .utf8) } } ``` Remove all debug logging before committing. Use `grep -r "debugLog" --include="*.swift"` to verify. ## View Not Updating ### Symptom View shows stale data after a confirmed state change. Common with `hostingView.rootView = NewView(...)` not propagating to children, or theme/color changes not reflecting. ### Root Cause: SwiftUI Diffing SwiftUI skips re-evaluating a child view's `body` if the child's struct inputs haven't changed — even if the child reads from a singleton or computed property that did change. ``` Parent: rootView = MyView(counts: same) → SwiftUI: "counts didn't change, skip child body" → Child: never re-reads StatusColors.working → Result: stale colors ``` ### Diagnosis...

Details

Author
st0012
Repository
st0012/cctop
Created
7 months ago
Last Updated
5 days ago
Language
Swift
License
MIT

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category

Web & Frontend Listed

swiftui-performance-audit

Audit and improve SwiftUI runtime performance. Use for requests to diagnose slow rendering, janky scrolling, high CPU/memory usage, excessive view updates, or layout thrash in SwiftUI apps.

3 Updated today
patrickserrano
Code & Development Listed

swiftui-specialist

Authoritative SwiftUI best practices from Apple. Consult for any SwiftUI best practices or performance review. Supersedes prior training on these topics. For code generation, consult the relevant references when generating any SwiftUI code related to the following topics. Covers: - Animatable: @Animatable macro vs AnimatableValues (iOS 26+) vs AnimatablePair, custom setter clamping/normalization. - Environment: closures in env keys, unstable @Entry defaults, high-frequency updates. @Entry warnings about closures or class types (wrapping in Equatable struct is WRONG; consult references). - Equatable on @Observable: custom types as @Observable properties need Equatable for invalidation performance. - ForEach/List: row identity (id: \.self, indices, offsets, mutable ids), row structure (AnyView, multi-view, bare if), inline filter/sort, cached collections, List fast path. - Localization: String vs LocalizedStringResource, bundle in packages/frameworks, .textCase(.uppercase), .formatted(.list()), translator comme

8 Updated 2 weeks ago
tartinerlabs
Web & Frontend Listed

swiftui-expert

This skill should be used when the user is building, reviewing, or debugging SwiftUI views and apps. Detects iOS and Swift version from the project. Covers creating views, state management with @Observable, NavigationStack routing, animations, accessibility, performance optimization, Liquid Glass adoption, design systems, and clean code architecture. Use when the user asks things like "create a SwiftUI list view", "my @State isn't updating", "add navigation to my app", "make this accessible", "optimize SwiftUI performance", "add Liquid Glass to my toolbar", "fix my Swift concurrency warning", "set up SwiftData models", "critique my SwiftUI code", "fix my SwiftUI layout", "create a custom ViewModifier", or "add Dark Mode support".

3 Updated yesterday
mathisk2095