Authors XCUIest UI tests for iOS / iPadOS / tvOS and macOS desktop apps - uses the three-class XCUIApplication / XCUIElement / XCUIElementQuery pattern, sets accessibility identifiers on production code, runs via `xcodebuild test` with destination, parses the `xcresult` bundle. The macOS desktop delta (platform=macOS destination flags, TCC privacy-permission resets, per-device performance baselines) is in references/macos.md. Use when an iOS or macOS app needs UI tests in Apple's first-party framework (no external runtime; native to Xcode).
72
91%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
XCTest UI testing for macOS desktop apps (AppKit, SwiftUI, Catalyst) uses the
same three-class XCUIApplication / XCUIElement / XCUIElementQuery pattern,
the same accessibility-identifier locator strategy, and the same XCTAssert*
macros as the iOS workflow in SKILL.md. Per Apple's
Testing with Xcode - UI Testing chapter, "UI Testing in Xcode
rests on two core technologies: the XCTest framework and Accessibility."
This reference covers only what differs on macOS.
There is no simulator: -destination targets the host Mac directly.
# Run the full test bundle on the host Mac
xcodebuild test \
-project MyApp.xcodeproj \
-scheme MyApp \
-destination 'platform=macOS' \
-resultBundlePath build/result.xcresult
# Run a single test class / method
xcodebuild test -project MyApp.xcodeproj -scheme MyApp \
-destination 'platform=macOS' \
-only-testing:MyAppUITests/CheckoutUITests/testCheckoutHappyPath// SwiftUI
Button("Sign In") { … }
.accessibilityIdentifier("signInButton")
// AppKit
signInButton.setAccessibilityIdentifier("signInButton")macOS gates Automation, Accessibility, and Screen Recording behind TCC (Transparency, Consent, and Control) consent prompts. The prompts are out-of-process - an XCUITest cannot click through them. Reset consent state before launch (per Jamf's TCC reset guide), or pre-grant via an MDM PPPC (Privacy Preferences Policy Control) profile on managed CI fleets:
for s in Automation Accessibility ScreenCapture; do
tccutil reset "$s" "$BUNDLE_ID" || true
doneHosted GitHub macOS runners are interactive sessions, so XCUIApplication
launches need no extra display setup. Self-hosted headless Macs need an
attached console or VNC session - XCTest UI cannot run under launchd alone.
# .github/workflows/macos-xctest.yml
jobs:
test:
runs-on: macos-14 # Apple Silicon
steps:
- uses: actions/checkout@v5
- uses: maxim-lobanov/setup-xcode@v1
with: { xcode-version: '15.4' }
- run: |
xcodebuild test \
-project MyApp.xcodeproj \
-scheme MyApp \
-destination 'platform=macOS' \
-resultBundlePath build/result.xcresult \
-enableCodeCoverage YES
- uses: actions/upload-artifact@v4
if: always()
with:
name: xcresult
path: build/result.xcresultResult parsing is identical to iOS (Step 7 in SKILL.md):
xcrun xcresulttool for JSON summaries and attachments; the open-source
xcresultparser converts .xcresult to JUnit XML for junit-xml-analysis.
XCUICoordinate; complex multi-app flows often need Appium's Mac2
driver instead.XCTestObservationCenter rather than out-of-process file
diffs.desktop-test-strategy-reference in the qa-desktop plugin.