Skip to content

ConsultingMD/swift-ui-debug-scan

swift-ui-debug-scan

CI Release codecov Swift Package Manager Platforms

Enhanced SwiftUI debugging with structured view insights and render tracking.

Quick Start

import SwiftUI
import SwiftUIDebugScan

struct FeatureRootView: View {
    var body: some View {
        List {
            FeatureLeafView()
            FeatureLeafView()
            FeatureLeafView()
        }
        .debugScan("FeatureRootView")
    }
}

Console Output:

🧩 [FeatureRootView]
    • 📂 file: FeatureRootView.swift
    • 📚 module: Feature
    • 🎨 redraws: 1
    • ⏱️ timestamp: 2025-07-21 14:05:40 +0000

Why Use This?

  • View Metadata: Track file, module, and render counts
  • Debug Complex UIs: Essential for large, server-driven applications
  • Performance Insights: Identify over-rendering and optimization opportunities
  • Targeted Debugging: Focus on root views without log noise

Usage Best Practices

✅ Apply to root views:

NavigationView {
    HomeScreen()
}.debugScan("HomeNavigation")

❌ Avoid on leaf views:

// Avoid - creates excessive log output
Text("Button").debugScan("ButtonText")

Recommended targets:

  • Screen root views
  • Major container views
  • Complex custom components
  • Views with performance concerns

Advanced Features

Verbose Mode

Set SWIFTUI_DEBUG_SCAN_VERBOSE=1 for detailed diagnostics:

  • 🧵 Call stack and thread info
  • 💾 Memory and CPU usage
  • ⏱️ Performance timing
  • 📊 System metrics

Installation

Option 1: Swift Package Manager (Recommended)

dependencies: [
    .package(url: "https://github.com/ConsultingMD/swift-ui-debug-scan", from: "0.2.0")
]

Xcode: File > Add Packages → Enter URL above

Option 2: Direct File Integration (Zero Dependencies)

  1. Download DebugScan.swift
  2. Drag the file into your project
  3. Skip the import SwiftUIDebugScan line - start using .debugScan() immediately

Contributing

Contributions welcome! See CONTRIBUTING.md for guidelines.

Quick fixes: Fork → Change → Test → PR
New features: Open issue first to discuss

About

Lightweight SwiftUI debugging modifier for tracking view renders and performance.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages