skills/hierarchy/SKILL.md
Dump and analyze the live accessibility hierarchy for the current simulator screen. Use to debug why a test can't find an element, inspect what identifiers are set, or understand the element tree before writing flows.
npx skillsauth add grantiva/swift-assist hierarchyInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Dump the live accessibility hierarchy from the running app and analyze it. Use this when a test can't find an element, when you want to verify that .accessibilityIdentifier() modifiers are applied correctly, or when you're planning a new flow and need to know what the hierarchy actually exposes.
/swift-assist:hierarchy
/swift-assist:hierarchy --screen=LandmarkDetail
/swift-assist:hierarchy --filter=button
/swift-assist:hierarchy --json
--screen=<ViewName>: Navigate to a specific screen first before dumping (uses computer use)--filter=<text>: Filter output to elements whose name, label, or identifier contains this text--json: Output raw JSON instead of formatted treeCheck that the Grantiva runner is active:
grantiva runner start --bundle-id <BUNDLE_ID> --simulator "<SIMULATOR>"
Read bundle ID and simulator from grantiva.yml. If the runner fails to start, stop and tell the user to run /swift-assist:init first.
If --screen was provided, use computer use to navigate to that screen before dumping the hierarchy. This may involve tapping tabs, navigation links, or buttons to reach the target view.
grantiva runner dump-hierarchy
This queries the live XCUITest element tree from the running app.
Format the raw hierarchy into a readable tree. Show element type, label, name (accessibility identifier), and value for each element:
[XCUIElementTypeApplication] label="MyApp"
[XCUIElementTypeWindow]
[XCUIElementTypeTabBar] label="Tab Bar"
[XCUIElementTypeButton] name="home-tab" label="Home"
[XCUIElementTypeButton] name="settings-tab" label="Settings"
[XCUIElementTypeScrollView]
[XCUIElementTypeStaticText] label="Welcome"
[XCUIElementTypeButton] name="get-started-button" label="Get Started"
[XCUIElementTypeButton] label="Sign In" ← no identifier
Mark elements without an accessibility identifier with ← no identifier.
If --filter was provided, show only matching elements and their ancestors for context.
After the tree, print a summary:
Summary
=======
Total interactive elements: 12
With identifiers: 9 (75%)
Without identifiers: 3
Elements without identifiers:
[XCUIElementTypeButton] label="Sign In"
[XCUIElementTypeTextField] label="Email"
[XCUIElementTypeSwitch] label="Remember Me"
Run /swift-assist:doctor --fix to add missing identifiers.
Call out elements that tests commonly have trouble with:
label not name for tappingDefault (formatted tree): Best for human reading and debugging.
--json: Outputs the raw JSON from grantiva runner dump-hierarchy for piping or programmatic use.
--screen navigation fails, dump the hierarchy of wherever the app currently is and note that navigation didn't reach the targettesting
Run visual regression testing using Grantiva's diff pipeline. Capture screenshots, compare against baselines, and report visual differences. Use for catching unintended UI changes.
testing
Approve current VRT captures as new baselines. Can approve all or specific screens selectively. Use after reviewing /swift-assist:vrt results.
testing
Run generated test flows against the app in the simulator using Grantiva. Use after /swift-assist:make-tests to execute and validate your user flows.
development
Add the UI_TESTING / .mock services pattern to the app entry point so Grantiva can run tests with deterministic data and no live server. Use before make-tests when the app talks to an API.