mirror of https://github.com/garrytan/gstack.git
The /elements walker returned only top-level `_UIHostingView` /
`HostingView` shells on SwiftUI screens — three entries for a full
Dashboard, all with empty identifier/label and a 0,0,390,844 frame.
SwiftUI vends its AX leaves through the indexed accessor
(`accessibilityElementCount` + `accessibilityElement(at:)`) on the
hosting container, not through `accessibilityElements` (which returns
nil OR an empty array). The previous walker only fell through to the
indexed path on nil, not on empty — so SwiftUI leaves were silently
dropped.
Fix is three coordinated changes to ElementsBridgeImpl plus an opt-in
escape hatch:
1. Force materialization via `UIAccessibility.post(.layoutChanged, …)`
before the walk. Public API, no-op when VoiceOver already populated
the tree, doesn't speak.
2. Always run the indexed accessor when `accessibilityElements` is nil
OR empty. This is the actual SwiftUI path.
3. Read identifier/label/value/traits/frame from synthetic AX elements
via KVC over the documented `UIAccessibility` informal protocol
property names — safe and version-independent across the private
element classes (`_AXSnapshotElement`, `_UIAccessibilityElementMockView`, …).
4. New `.gstackProbe("identifier")` SwiftUI ViewModifier + thread-safe
`GstackProbeRegistry` for views the AX tree refuses to surface
(intentionally hidden, custom Canvas, decorative Shape stacks). Probe
sets `.accessibilityIdentifier(_:)` AND registers (id, frame) in the
registry; the walker merges these in as synthetic entries tagged
`"source":"gstack-probe"`.
Also filters empty container synthetic nodes (no label/id/value/traits)
that were clogging the output before.
Docs in `ios-qa/docs/swiftui-accessibility.md` cover the root cause,
what the fix does/doesn't address, and when to reach for `.gstackProbe`
vs vision-based coordinate tapping.
Typechecks clean against iOS 16 + iOS 17 SDKs, Swift 6 strict
concurrency. Live-device validation pending — PR author will port to
downstream app + report new element count.
|
||
|---|---|---|
| .. | ||
| swiftui-accessibility.md | ||
| tailscale-acl-example.md | ||