name: inspect-view
description: Inspect the view hierarchy of a running simulator app using axe view. Use when debugging layout issues, investigating view structure, or diagnosing UI problems in a running app.
argument-hint: [--app ] [0xADDRESS] [--frontmost] [--depth N]
allowed-tools: Bash(axe *), Read, Grep
View Hierarchy Inspector
Inspect the UIKit/SwiftUI view hierarchy of a running app to diagnose layout issues.
Steps
1. Identify the running app
If the user hasn't specified an app name, list running processes first:
axe ps
2. Get the view hierarchy
Pass all user arguments directly to axe view:
axe view $ARGUMENTS
Common invocation patterns:
- Full tree:
axe view --app MyApp
- Frontmost only:
axe view --app MyApp --frontmost
- Limited depth:
axe view --app MyApp --depth 3
- Specific view detail:
axe view 0x10150e5a0 --app MyApp --swiftui compact
Note: --swiftui (none/compact/full) is only valid in detail mode (when a 0x address is provided).
3. Analyze the hierarchy
Examine the view tree output (YAML format) and identify:
- Unexpected nesting: Views wrapped in unnecessary containers
- Frame issues: Zero-sized frames, overlapping views, off-screen elements
- Constraint violations: Ambiguous layouts or conflicting constraints
- Hidden views: Elements with
isHidden: true or zero alpha
- SwiftUI structure: Body composition and modifier chains (when using
--swiftui)
4. Correlate with source code
If the user provides source file context, correlate the hierarchy nodes with the SwiftUI/UIKit source to pinpoint where issues originate.
5. Report findings
Present:
- A simplified view of the relevant hierarchy section
- Identified issues with their view addresses
- Suggested code changes to fix layout problems
Tips
- Use
--depth 3 to limit output for deeply nested hierarchies
- Use
--frontmost to focus on the visible view controller
- In detail mode output, the SwiftUI tree can be large. Focus on the relevant section.
Prerequisites
Run this if the command fails because axe is not found::
curl -fsSL https://raw.githubusercontent.com/k-kohey/axe/main/install.sh | sh