// A hosted SwiftUI view builds its accessibility tree only while something// reads it — VoiceOver, or UI automation. A unit test that walks the tree of// a page it hosts (a deck's counter, a note's page label, Select all) on a// fresh job simulator, where neither runs, finds the hosting view's one// empty node. The test turns the simulator's automation accessibility on for// its own process first, as an XCUITest run would; nothing in the app reads it.#if os(iOS)importDarwinimport UIKitenumHostedAccessibility {/// Turns automation accessibility on for this process, once; false when the simulator's library will not say how. @MainActor @discardableResultstaticfunc enable() -> Bool {if enabled { returntrue }guardlet library = dlopen("/usr/lib/libAccessibility.dylib", RTLD_NOW),let set = dlsym(library, "_AXSSetAutomationEnabled") else { returnfalse } unsafeBitCast(set, to: (@convention(c) (Int32) -> Void).self)(1) enabled = truereturntrue } @MainActor privatestaticvar enabled = false}#endif