Mac hosting guide

macOS Accessibility Keyboard Navigation Audit

Run performAccessibilityAudit() in an XCUITest, then walk Tab by hand once and commit a focus-order CSV to diff on every pull request. Both checks run on any Mac with Xcode, including Figment's Intel VM.

Figment editorial teamPublished Updated Facts checked November 10, 2026

Figment Mac plans

US East. Pay before use. Hourly and daily too.

Intel Mac VM4 shared vCPUs, 4GB RAM, 80GB SSD$25per monthApple Silicon Mac VM4 shared vCPUs, 4GB RAM, 65GB SSD$39per monthDedicated M4 Pro12-core CPU, 24GB RAM, 512GB SSD$199per month

Minimum first purchase: $25 of account credit, used for your rental.

Audit macOS keyboard navigation with two checks: a short XCUITest that calls performAccessibilityAudit() on your main window, and a manual Tab-walk that records a focus-order CSV you diff against a checked-in baseline on every pull request. The automated audit finds element defects such as missing labels. The Tab-walk catches order problems and keyboard traps, which tooling cannot judge.

What does the keyboard audit prove?

It checks WCAG 2.4.3 Focus Order, a Level A criterion: when a view supports sequential navigation and the sequence affects meaning or operation, focusable components must receive focus in an order that preserves meaning and operability. The WCAG 2 text is written for web pages, but accessibility teams apply it to native macOS apps because keyboard users navigate both the same way.

Three failure modes show up repeatedly in macOS reviews:

  • Controls are skipped because the view paints its own focus ring but exposes no accessibility element.
  • Tab order contradicts the visible layout because view ordering in a stack does not match the geometry.
  • A focused element returns focus to itself and traps the keyboard user in a two-element loop.

The automated audit catches the first on its own. The manual Tab-walk catches the second and third and gives reviewers a stable artifact to diff.

How do I enable full keyboard access on the Mac?

Run defaults write from Terminal, because macOS limits Tab focus to text fields and lists unless Keyboard navigation is turned on in System Settings.

defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
defaults read NSGlobalDomain AppleKeyboardUIMode
# Expected: 3

On a dedicated CI Mac, leave it at 3. On a shared workstation, revert to -int 2 after a run so standard behaviour returns. Relaunch the app under test so the change takes effect in that process.

Which XCUITest do I add?

Add the test below. It uses public API only. typeKey(_:modifierFlags:) with XCUIKeyboardKey.tab is documented on macOS. XCUIApplication.performAccessibilityAudit() is available on macOS 14 and later and checks every element on screen for missing labels, low contrast, action issues and parent-child problems. The textClipped, trait and dynamicType audit types are iOS-only, so if you narrow the scope on macOS, use .all.subtracting([.textClipped, .trait, .dynamicType]).

// AccessibilityAuditTests.swift
import XCTest

final class AccessibilityAuditTests: XCTestCase {

    // Populate this list from the manual worksheet below with the accessibility
    // identifiers your window exposes, in the Tab order the design requires.
    // Leave empty on first run; the Tab-order check will be skipped.
    let expectedFocusOrder: [String] = [
        // "searchField",
        // "filterButton",
        // "sortDateButton",
    ]

    func testElementLevelAudit() throws {
        let app = XCUIApplication()
        app.launch()
        try app.performAccessibilityAudit()
    }

    func testTabThroughExpectedOrder() throws {
        guard !expectedFocusOrder.isEmpty else {
            throw XCTSkip("expectedFocusOrder is empty; populate it from the manual worksheet first")
        }
        let app = XCUIApplication()
        app.launch()
        let window = app.windows.firstMatch
        XCTAssertTrue(window.waitForExistence(timeout: 5), "Main window did not appear")

        for identifier in expectedFocusOrder {
            app.typeKey(XCUIKeyboardKey.tab, modifierFlags: [])
            let target = window.descendants(matching: .any).matching(identifier: identifier).firstMatch
            XCTAssertTrue(target.waitForExistence(timeout: 2),
                          "After Tab, expected '\(identifier)' to be present in the window")
        }
    }
}

This is an untested example to adapt to your project. testElementLevelAudit fails on any element defect Apple's audit recognises, which is the class of problem tooling can decide without a human. testTabThroughExpectedOrder presses Tab once per listed identifier and checks each is present when it is that element's turn. It deliberately does not query focus directly: a reliable macOS focus check needs an undocumented KVC on hasKeyboardFocus, and pinning CI to it is fragile across Xcode releases. The manual worksheet carries the precise focus check, and the automated test enforces the ordered list you derive from it.

How do I walk Tab by hand and record a baseline?

Follow the worksheet below once per window. It takes a focused engineer roughly five minutes and produces a diff-friendly CSV that reviewers keep in the repository.

  1. Launch the app under test with full keyboard access enabled.

  2. Click once in the title bar to focus the window. If some controls still refuse Tab on your macOS version, press Fn+Ctrl+F7 to toggle keyboard access so Tab moves between all controls.

  3. Create baseline-focus-order.csv with the header:

    step,label,role,identifier,notes
    
  4. Press Tab. Record the step number, the VoiceOver label you hear (turn VoiceOver on with Cmd+F5 if you cannot read the focus ring), the control type (button, textField, checkBox, popupButton, tab, menuItem, list) and, if your team sets accessibility identifiers, the identifier. Leave notes empty.

  5. Repeat until the ring returns to the first control or leaves the window. If the same control is focused twice in a row before the cycle closes, mark that row's notes column WCAG-2.4.3-FOCUS-TRAP and stop.

  6. Count the focusable controls visible in the window by eye. If that number is larger than the row count, the missing controls probably fail both SC 2.4.3 and SC 2.1.1 Keyboard. Add a row with notes = WCAG-2.1.1-UNREACHABLE for each one and link the bug.

  7. Commit the CSV next to the UI test target. Copy the identifier column into expectedFocusOrder so the automated check enforces the agreed order on every pull request.

Keep each CSV short. A dialog with twelve focusable controls produces twelve rows. A settings window with a sidebar and three panes is three CSVs, one per pane.

A clean pass looks like this:

step,label,role,identifier,notes
1,"Search",textField,searchField,
2,"Filter",button,filterButton,
3,"Sort by Date",button,sortDateButton,
4,"First result",row,result-0,

A trap looks like this:

3,"Filter",button,filterButton,
4,"Filter",button,filterButton,WCAG-2.4.3-FOCUS-TRAP

Typical defects the worksheet surfaces:

  • A custom view that paints a focus ring but exposes no accessibility element is missing from the CSV entirely.
  • A modal that returns focus to an unrelated control on dismiss shows an identifier after the modal that does not match the one before it.
  • Toolbar items reachable only via Fn+Ctrl+F7 on older macOS versions are missing from the Tab-only walk by design, so give them a separate audit row.

How do I diff the baseline in CI?

Run the tests from the command line, export what the audit attached to the result bundle, then diff the CSVs.

xcodebuild test \
  -scheme "$YOUR_SCHEME" \
  -destination 'platform=macOS' \
  -resultBundlePath Build/Results.xcresult

xcrun xcresulttool export attachments \
  --path Build/Results.xcresult \
  --output-path artifacts/

Compare the committed CSV against the one from the latest worksheet pass (regenerated by hand after an intentional UI change, or by a helper you write that walks expectedFocusOrder and captures the labels):

diff artifacts/focus-order.csv baseline-focus-order.csv

Any line difference fails the step: a new control, a renamed label or a reordered stop. Update the baseline in the same commit that changes the UI so reviewers see the focus-order diff next to the code change. Treat an unexplained diff like a failing unit test and block the pull request until the change is justified.

Does a keyboard navigation audit need more than a remote desktop?

Any plan with remote desktop works, because the audit needs only macOS, Xcode and a desktop session for the Tab-walk. The Intel Mac VM ($25 a month, $2 a day) runs macOS Sequoia and supports Xcode 26.3 or earlier, which covers performAccessibilityAudit() on macOS 14 and later. It cannot run Xcode 26.4 or later, arm64-only binaries or visionOS, so choose the Apple Silicon Mac VM ($39 a month, $6 a day) for those. Install Xcode from Apple yourself, using your own Apple account. See the Mac hosting plans and check the macOS version shown before purchase against Apple's Xcode table.

Related testing guides:

Which Figment Mac fits this work?

Intel Mac VM from $25 a month, Apple Silicon Mac VM from $39, or a Dedicated M4 Pro for $199. Hourly and daily plans too. You pay before use, starting with at least $25 of account credit.

Choose a Mac plan