Improve Your App With This One Neat Trick

Accessibility refers to a number of features that come native to iOS devices. It allows individuals who may have an impairment use their device without issue. These features include things like VoiceOver, Dynamic Type, Assisted Touch, and various others.

VoiceOver allows users with a visual impairment to navigate through the app with relative ease. Why relative? Because often developers (me, included) can forget to develop with accessibility in mind. To initiate VoiceOver, visit Settings > General > Accessibility > VoiceOver and tap to enable it. After you’ve done this, visit an app (perhaps your own) and see how difficult — or easy — it might be for someone with a visual impairment to use it.

Dynamic Type allows users to increase or decrease the font size of their phone. Again, this helps users with a visual impairment to clearly see and read the content on the screen. This can also be enabled in the Accessibility section of the settings page.

With these accessibility settings enabled, the way in which a user interacts with your app will change. For example, with VoiceOver enabled a user would double tap to select an element, or trigger an action. Left and right swiping will move a user onto the next accessibility element in the hierarchy. Swiping up and down will move through the accessibility elements in the hierarchy and read the elements accessibility label. If you have some tap gestures or other gesture recognisers, it’s important to be aware of this crucial API in order to avoid interfering with interactions that a user expects to work in a certain way.

XCUITesting & Accessibility

So how do these two seemingly unrelated features relate? XCUITests hook into the accessibility elements of your application in order to read values, trigger actions, and check existence. If an element is not visible to the accessibility hierarchy, it won’t be visible to the Xcode UI test runner. In writing UI tests, you’ll inadvertently improve the accessibility of your app.

In rare cases, it can be hard to convey the value of writing any kind of test. Clients or Product Owners might not understand that tests prevent bugs and keep tech debt to a minimum, mostly because there’s no product at the end of it. A PO can’t interact with a unit or integration test. What a product owner can do, however, is inform stakeholders that as a result of spending time writing these tests, we’ve increased accessibility and, as such, our potential user base. Automated UI tests can reduce regression testing cycle times also, meaning the cost of manual testers is reduced as well.

I’ll be going into making your app more accessible in a future blog post, because it requires a full post of attention. For now, take a look at the official documentation here as a starter for ten.