Skip to content

Latest commit

 

History

History
92 lines (71 loc) · 2.64 KB

File metadata and controls

92 lines (71 loc) · 2.64 KB

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:

🧩 [MainView]
    • 📂 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:

// Don't do this - too much noise
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

Swift Package Manager:

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

Xcode: File > Add Packages → Enter URL above

Contributing

Contributions welcome! See CONTRIBUTING.md for guidelines.

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