r/iOSProgramming • u/Few-Pilot7575 • 1d ago
Discussion Agent written SwiftUI keeps breaking accessibility and nobody notices
Our iOS app has a lot of older users, and accessibility matters for us, about 9% of sessions use VoiceOver or a large dynamic type size. Since agents started writing most new screens, our accessibility has been quietly getting worse.
What a blind user's email made us find last month:
- icon only buttons with no accessibility label, so VoiceOver reads "button"
- a custom card that groups 5 elements into one, so you can't reach the delete action
- text in fixed frames that gets cut off at larger type sizes
- a sheet that traps focus when it opens
coderabbit catches some of it in review, like an Image used as a button without a label. But reading order and what happens at the largest text size don't show up in a diff, and none of us test with VoiceOver on every PR.
What's helped so far:
- accessibility snapshot tests at 3 dynamic type sizes for our main screens
- a short accessibility section in the agent's instructions
- one person doing a 10 minute VoiceOver pass before each release
How do other iOS teams keep accessibility from slipping when agents write the UI? Anything automated that actually catches the VoiceOver problems?
7
u/onefish857 23h ago
performAccessibilityAudit() in a ui test will catch a lot of the missing-label / contrast / hit-target stuff, it's been in xctest since ios 17. it still won't see a focus trap or a bad reading order though. for the card issue i'd just ban
.accessibilityElement(children: .combine)on any container that has its own buttons, that's a very common agent habit.3
u/dawedev 23h ago
Cheap trick for the large text part: make the agent add a #Preview at .dynamicTypeSize(.accessibility5) for every new screen. Then the cut-off fixed frames show up in Xcode before anyone opens a PR. Won't catch the focus trap, but it's one less thing for the manual pass.
2
u/dahiya_xa 22h ago
if you're on xcode 15+ add a ui test that calls app.performAccessibilityAudit() on your main screens. it catches missing labels, clipped text at large type, contrast and small hit targets automatically in ci, so it doesn't depend on someone remembering to check. you can filter the audit types if some are noisy at first. for the agent side, i'd put concrete rules in its instructions rather than general ones: every icon only Button gets an accessibilityLabel, no fixed heights on text, use .accessibilityElement(children: .combine) or .contain on purpose and expose custom actions for things like delete. focus traps and reading order still need a human pass, but the audit cuts what that person has to look for
2
u/trouthat 19h ago
You didn’t notice when you tested the app?
1
u/gnedyalkov 22h ago
running `performAccessibilityAudit()` inside XCUITest on the main screens catches missing labels and tiny tap targets automatically in CI. it won't catch bad VoiceOver reading order or weird custom grouping, so a quick manual pass still matters, but it stops agents from silently dropping `.accessibilityLabel` on icon buttons.
1
u/dony266 21h ago
Have you tried performAccessibilityAudit() in XCUITest (Xcode 15+)? It runs the Accessibility Inspector audit inside a UI test and fails on things like missing labels, small hit areas, contrast and clipped text with Dynamic Type. Put one test per main screen in CI and it catches a lot of the "button" with no label problem before a human ever sees it. It won't catch reading order though, so your 10 min VoiceOver pass is still worth keeping.
1
u/Some-Kitchen8332 21h ago
keeping `.accessibilityLabel()` on the same line as the image makes it harder for the agent to leave it out. a quick pass for anything voiceover just calls button usually catches the ones that slip through.
1
u/SwiftlyJon 20h ago
This seems pretty easy as a skill for the agent, or as part of a review. In fact, the Copilot reviewer brings it up a lot, despite the fact the app doesn't really support accessibility (don't ask). Reveal is pricy, but it has great accessibility tools and an MCP server agents can use to inspect the accessibility hierarchy.
1
u/Vybo 19h ago
My setup uses Argent to check if all elements have accessibility traits using the same tree the inspector you’d use show. Then it’s run through manual QA. No snapshot or automated testing ever replaced manual QA in any of the teams I worked with.
Also, agentic development actually allowed us to better cover the app for voiceover and debug for large type issues.
1
u/Responsible-Aerie968 14h ago
I'd start with the exact card that broke. Put two cards on screen, find “Delete” within the second one by its spoken label, tap it and check that only the first card is left. The important bit is running that test on the broken build first. If it passes, XCUITest can still reach something your VoiceOver user couldn't.
For the manual pass I'd add one step after dismissing the sheet. Where did focus land? Getting dumped back at the top of a long list every time you close a sheet is miserable.
1
u/Difficult_Duty2198 3h ago
what helped me was turning voiceover on and swiping through each new screen once. you spot unlabeled buttons really fast that way
•
u/Kozakiewicz122112 22m ago
The card that swallows delete is what taught me this: grouping with .accessibilityElement(children: .combine) hides the action, .contain keeps children reachable, and a named .accessibilityAction puts delete back on the container. Since then our agent prompt says every grouped card must declare its action.