What this thread does
Run performAccessibilityAudit after the target screen settles, capture each issue’s element and frame, and leave findings with missing identity unresolved.
Do first: add an iOS 17+ UI test that reaches a deterministic screen state and runs the full audit without exclusions; retain the result bundle and screenshots. Apple’s audit guide describes current-screen checks and automatic test failures.
Capture the finding before classifying it
1. Give important controls stable accessibility identifiers without replacing their spoken labels. Navigate to the intended screen, load fixed content and wait for a specific ready condition. Apple recommends identifiers for automation and auditing each relevant view in WWDC23. 2. Use the issue handler to record the audit type, both descriptions and optional element attributes. Return false to keep every finding reportable. Apple exposes an optional issue.element in XCUIAccessibilityAuditIssue; do not force unwrap it.
Illustrative code inside an iOS 17+ XCTestCase method; app is the launched application:
continueAfterFailure = true
try app.performAccessibilityAudit { issue in
var details = "type=\(issue.auditType)\n"
details += issue.compactDescription + "\n"
details += issue.detailedDescription + "\n"
if let element = issue.element, element.exists {
details += "id=\(element.identifier)\n"
details += "label=\(element.label)\n"
details += "elementType=\(element.elementType)\n"
details += "frame=\(element.frame)\n"
} else {
details += "identity=unresolved\n"
}
let text = XCTAttachment(string: details)
text.lifetime = .keepAlways
add(text)
return false
}
3. Attach a full-screen screenshot immediately before and after the audit, using XCTAttachment(screenshot: XCUIScreen.main.screenshot()) and .keepAlways. Name them with the screen, scroll position and configuration. Text and screenshot attachments are supported by XCTAttachment. Avoid navigation or mutations inside the handler. 4. Keep one evidence row per issue: run/result bundle, test identifier, device/OS, locale, appearance, text size, Bold Text setting, scroll state, audit type, identifier/label/type, frame and attachment names. Frames use screen coordinates; record the mapping to image pixels before cropping. Apple frame API. This row format is a recommended triage convention.
Diagnostic: audit finding has no identifiable element
Open the failing test in Xcode’s Report navigator and inspect its issue screenshot. Reproduce the same screen with Accessibility Inspector. Toomas Vahter’s 2024-02-26 Silky Brew report describes a hit-region finding whose element was not highlighted by the UI test; Inspector located the row. Missing identity is not proof of an offscreen element or false positive.
Only add an exception after identifying the actual content and retaining evidence for that exact case. Constrain it by audit type plus stable element identity and screen state; missing element or empty identifier must not match. Never suppress all contrast/clipping findings or infer an exception from a similar description in an older run. Apple’s filtering example shows that true ignores the issue and false reports it.
Check the rendered state
| Concern | What to collect and decide |
|---|---|
| Contrast | Record resolved foreground/background colors, size, weight and appearance for the identified text; inspect its actual background, including materials, gradients and disabled state. Keep the image crop with its frame. |
| Clipping | Exercise long localized content and accessibility Dynamic Type sizes; look for truncation, compressed height and missing content at the actual scroll position. Audit the next viewport after scrolling. |
| Pinned controls | Capture top, middle and bottom scroll positions, plus keyboard-visible states where relevant; assert the intended control frame remains within the visible content region and inspect overlap with content. |
| Focus | Exercise the actual VoiceOver navigation sequence and activation path; preserve the screen and expected spoken order. A geometry snapshot alone cannot establish that sequence. |
Apple’s Inspector guide defines contrast and clipping checks and warns that passing audits does not guarantee accessibility. The viewport and keyboard cases above are additional recommended checks; an audit only covers the current screen.
For a numeric text-color check use WCAG’s (Llighter + 0.05) / (Ldarker + 0.05) relative-luminance ratio. WCAG 2.2 AA uses 4.5:1 for ordinary text and 3:1 for qualifying large text, with defined exceptions. Do not round a near miss upward or measure arbitrary antialiased edge pixels. A palette calculation supports a known color pair; it cannot identify which element an audit flagged. These are WCAG text-contrast criteria, not a promise that Apple’s audit uses an identical algorithm or a legal conclusion about a native app.
Bold Text needs a rendered transition
SwiftUI’s legibilityWeight reflects the Bold Text accessibility setting. A test-only .environment(\.legibilityWeight, .bold) exercises a subtree from iOS 16; also check the system setting. Environment value, LegibilityWeight.
Recommended check: apply the override at the intended root, navigate into and back out of a NavigationStack destination, then capture the body, list rows, title and toolbar. Also repeat with system Bold Text enabled. Do not assume a descendant’s environment value establishes how every navigation control rendered.
Wait on an observable condition that the app updates after applying its text/layout state, then take fresh frames and screenshots and rerun contrast/clipping checks. XCTNSPredicateExpectation can express that condition; its fulfillment does not itself guarantee pixel presentation. Inspect the resulting image. A fixed delay or a source-level environment assertion is not render evidence.
Evidence and limits
- Toomas Vahter, 2024-02-26: first-person app report of a hit-region issue, missing highlight and Inspector diagnosis. Combining that row’s labels addressed his case; it is not a general fix for every small control.
- Dheeraj Neelam and Manish Verma, Intuit, 2024-07-09: describe their iOS accessibility practices and recommend UI-test audits alongside native accessibility support.
These reports do not establish universal false-positive rates. Automated audits supplement manual assistive-technology interaction.
Not for: generic simulator compilation, URLSession fixtures or Keychain persistence tests.
Started from a post by @editor, packaged by the editor. Original post