Loupe
A SwiftUI debugging toolkit for visualizing renders, layouts, and measurements.
Install / Use
/learn @Aeastr/LoupeREADME
Overview
Loupe provides runtime debugging tools for SwiftUI applications. Visualize render cycles, inspect layout bounds, track positions, and overlay precision grids—all with minimal setup and zero impact on production builds.
Render Debugging
.debugRender()- Visualize when views re-render with colored backgrounds.debugCompute()- Visualize when views re-initialize with red flashesRenderCheck- Batch debugging wrapper for multiple views
Layout Inspection
VisualLayoutGuide- Display bounds, safe area insets, and dimensionsDraggablePositionView- Track coordinates with draggable overlaysVisualGridGuide- Overlay precision alignment grids
Container Shapes (iOS 26+)
VisualCornerInsetGuide- Visualize ConcentricRectangle and container shapes
Installation
dependencies: [
.package(url: "https://github.com/Aeastr/Loupe.git", from: "1.0.0")
]
import Loupe
Usage
Render Debugging
See when views re-render or re-compute:
Text("Count: \(count)")
.debugRender() // Shows re-renders with colored backgrounds
.debugCompute() // Shows re-computations with red flashes
Batch debug multiple views:
RenderCheck {
Text("A")
Text("B")
Text("C")
}
Layout Inspection
Display bounds, safe area insets, and dimensions:
ZStack {
Color.blue
.overlay {
VisualLayoutGuide("Content Area")
}
}
Enable dragging and persistence:
VisualLayoutGuide("Debug View")
.visualLayoutGuideInteractions(dragEnabled: true, persistenceEnabled: true)
Position Tracking
Monitor coordinates with draggable overlays:
DraggablePositionView("Tracker")
.draggablePositionViewInteractions(dragEnabled: true)
Grid Overlays
Add precision alignment grids:
VisualGridGuide("8pt Grid", squareSize: 8, fit: .exact)
.ignoresSafeArea()
Container Shapes (iOS 26+)
Visualize ConcentricRectangle and container shapes:
VisualCornerInsetGuide("Container Shape")
.padding(20)
.containerShape(RoundedRectangle(cornerRadius: 32))
How It Works
All debugging tools are conditionally compiled with #if DEBUG. They are automatically excluded from release builds—no manual cleanup required, no performance impact in production.
- debugRender() uses a
Canvasthat generates a random color on each render - debugCompute() uses a
LocalRenderManagerthat triggers a red flash on view initialization - VisualLayoutGuide uses
onGeometryChangefor efficient size/inset tracking with automatic collision detection - VisualGridGuide calculates optimal square sizes using GCD for perfect tiling
Contributing
Contributions welcome. Please feel free to submit a Pull Request.
License
MIT. See LICENSE for details.
Related Skills
node-connect
349.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
