Run and stabilize iOS tests (XCTest, XCUITest, Swift Testing) on simulators and devices with xcodebuild/simctl: choose destinations, manage simulator state, control flakes...
High-signal iOS test execution and flake control for XCTest, XCUITest, Swift Testing, xcodebuild, xcresult, and simctl.
Pair this skill with software-ios-native when the work is part of a native iOS rewrite or a Codex / Claude Code implementation loop.
Core docs:
| Need | Go to |
|---|---|
| Run the iOS test workflow | ## Workflow |
| Load current defaults and command patterns | ## Defaults and ## xcodebuild Patterns |
| Control flakes and destinations | ## Flake Control |
| Load templates and references | ## Navigation |
xcresult artifacts always enabled.SWIFT_TESTING_XCTEST_INTEROP_MODE=limited in your test plan environment.-workspace or -project-scheme and optional -testPlanxcresult, coverage, screenshots, logs, diagnostics| Command | Purpose |
|---|---|
xcodebuild -list -workspace MyApp.xcworkspace |
List schemes |
xcodebuild -scheme MyApp -showdestinations |
Show valid destinations |
xcodebuild -scheme MyApp -showTestPlans |
Show available test plans |
xcrun xctrace list devices |
List physical and simulator devices |
xcrun simctl list devices available |
List available simulators |
xcrun simctl boot "<simulator-name>" |
Boot a simulator |
xcrun simctl bootstatus booted -b |
Wait for boot completion |
xcrun simctl uninstall booted <bundle-id> |
Remove stale installed app before a smoke pass |
Persist booted UDID to .simulator-udid (gitignored) in the select-simulator.sh step |
Stop scripts read this file back and call xcrun simctl shutdown <UDID> plus xcrun simctl terminate <UDID> <bundle-id> — terminating exactly the simulator that was booted. Replaces pkill -f Simulator, which shotguns unrelated dev / CI simulators. The UDID file is the contract between run and stop scripts. |
xcodebuild test -scheme MyApp -destination 'platform=iOS Simulator,name=<simulator-name>,OS=latest' -resultBundlePath TestResults.xcresult |
Run tests on a simulator |
xcodebuild test -scheme MyApp -destination 'platform=iOS,id=<UDID>' -resultBundlePath TestResults.xcresult |
Run tests on a device |
xcodebuild build-for-testing ... then xcodebuild test-without-building ... |
Faster reruns |
xcrun xcresulttool get --path TestResults.xcresult --format json |
Inspect results programmatically |
xcodebuild ... -destination "generic/platform=iOS" build |
Compile-only build without a simulator |
xcodebuild archive -scheme MyApp -destination 'generic/platform=iOS' |
Exercise archive/signing path |
-resultBundlePath, and add coverage or diagnostics only when they serve the task.xcresult first, then reproduce a single failing test with -only-testing.xcresult, destinations, and flake control after the app is buildable and installable..app bundles, missing executables, or install/launch failures, route to software-ios-runtime-debugging.# Enumerate before an expensive run
xcodebuild test \
-scheme MyApp \
-testPlan Smoke \
-destination 'platform=iOS Simulator,name=<simulator-name>,OS=latest' \
-enumerate-tests \
-test-enumeration-format json
# Target one test
xcodebuild test \
-scheme MyApp \
-destination 'platform=iOS Simulator,name=<simulator-name>,OS=latest' \
-only-testing:MyAppUITests/LoginFlowTests/testHappyPath \
-resultBundlePath TestResults.xcresult
# Parallelize only when the suite is isolation-safe
xcodebuild test \
-scheme MyApp \
-destination 'platform=iOS Simulator,name=<simulator-name>,OS=latest' \
-parallel-testing-enabled YES \
-maximum-parallel-testing-workers 4 \
-resultBundlePath TestResults.xcresult
# Controlled retry for CI triage
xcodebuild test \
-scheme MyApp \
-destination 'platform=iOS Simulator,name=<simulator-name>,OS=latest' \
-retry-tests-on-failure \
-test-iterations 2 \
-test-repetition-relaunch-enabled YES \
-collect-test-diagnostics on-failure \
-resultBundlePath TestResults.xcresult
# Prove a flake locally
xcodebuild test \
-scheme MyApp \
-destination 'platform=iOS Simulator,name=<simulator-name>,OS=latest' \
-only-testing:MyAppUITests/LoginFlowTests/testHappyPath \
-run-tests-until-failure \
-test-iterations 25
waitForExistence, expectations, and state-based assertions over sleeps.-testLanguage and -testRegion when locale affects assertions.LocalizationStore.text / generated-catalog lookups are testable defects, not acceptable runtime assertions. Add or run catalog coverage before returning to UI polish.For auth, onboarding, billing, referral, and other backend-coupled flows, prefer a fixture-backed launch-environment harness over live credentials. Keep user variants explicit, keep the fixture branch in the same function as the real path, and treat .accessibilityIdentifier() strings as part of the test contract.
Load references/e2e-harness-and-selectors.md for:
Xcode test plans (.xctestplan) control which tests run, with what configuration, and in which environment. Use them to manage matrix-style test execution:
-testLanguage / -testRegion overrides per configuration.-testPlan PlanName in xcodebuild.AI-native tools now generate, execute, and maintain iOS UI tests with minimal manual scripting. Use them as a complement to XCUITest, not a replacement.
Current positioning:
Maestro + MaestroGPT + Maestro MCP: fast smoke and onboarding flow authoringTestSprite: self-healing AI-owned test generation and maintenanceDrizz: visual validation for design-heavy iOS apps| Scenario | Use |
|---|---|
| PR gate smoke tests (fast, deterministic) | XCUITest |
| Broad flow coverage with low authoring effort | Maestro + MaestroGPT |
| Self-healing test maintenance | TestSprite or Appium MCP |
| Visual correctness validation | Drizz |
| Deep state/network assertions | XCUITest |
| Release-candidate E2E sweep | Drizz + real device matrix |
For fuller tool coverage, MCP integration patterns, and the decision framework, load qa-testing-mobile/references/ai-native-testing.md.
xcresult bundles and deciding the next reproduction step| Scenario | Use Instead |
|---|---|
| Product architecture, app implementation, SwiftUI rewrite, or Xcode agent workflow | software-ios-native |
| Build/install failures, stale app suspicion, bundle executable missing, or simulator/package debugging | software-ios-runtime-debugging |
| Cross-platform mobile test strategy | qa-testing-mobile |
| Release-wide quality strategy | qa-testing-strategy |
waitForExistence and expectations over sleeps-testLanguage and -testRegion when locale affects assertions-resultBundlePath artifacts for every CI rungeneric/platform=iOS destination when simulator service is crashed or unavailable — validates Swift compilation without requiring a running simulatorCodable decoders with hand-crafted JSON payloads for missing, null, and unexpected fields — especially for API response models where the backend has evolved. Use JSONDecoder().decode(T.self, from: json) with minimal payloads that omit optional fields and payloads that include unknown keys. Focus on fields the backend has changed or may omit.| Resource | Purpose |
|---|---|
| references/e2e-harness-and-selectors.md | Deterministic fixture harnesses, selector discipline, and E2E landing rules |
| references/swift-testing.md | Comprehensive Swift Testing: assertions, parameterized tests, tags, traits, async patterns, confirmations, Swift 6.2 features, Xcode 26 additions (image attachments, severity levels, XCTest interop change), and XCTest migration |
| references/xctest-patterns.md | XCTest patterns for unit, integration, and performance tests |
| references/xcuitest-patterns.md | XCUITest authoring and flake control |
| references/simulator-commands.md | Current simctl commands worth using in automation |
| references/snapshot-testing-ios.md | Snapshot testing with current caveats |
| references/ios-ci-general.md | Provider-neutral iOS CI guidance, including archive-path and fresh-clone checks |
| references/ios-ci-github-actions.md | GitHub Actions specifics and runner drift checks |
| references/ios-ci-optimization.md | Compatibility index for the CI reference split |
| references/ios-version-and-vision-pro.md | iOS 26 Liquid Glass snapshot impact, iOS 18 predictive back and Apple Intelligence testing, visionOS 26 destination syntax, Reality Composer Pro asset testing, hand-tracking simulator limits |
| ../qa-testing-mobile/references/localization-testing.md | Layered localization coverage for mobile UI and backend-served content |
| ../qa-testing-accessibility/SKILL.md | Accessibility-specific QA gates, screen-reader coverage, and conformance boundary guidance |
| data/sources.json | Curated external references |
| Script | Purpose |
|---|---|
| scripts/xcresult_to_junit.py | Convert .xcresult bundle to JUnit XML for CI publishing (Xcode 16+, stdlib only) |
| scripts/README.md | Usage guide and CI integration examples (GitHub Actions, Bitrise) |
| Template | Purpose |
|---|---|
| assets/template-ios-ui-test-stability-checklist.md | Review checklist for UI-test determinism |
iOS testing request
-> Classify layer: Swift Testing, XCTest, XCUITest, snapshot, or release smoke
-> Pick exact scheme, destination, simulator/device, OS, and runner mode
-> Stabilize fixtures, accessibility identifiers, permissions, and time/locale
-> Run the smallest targeted test or xcresult-producing command
-> Parse artifacts, screenshots, logs, and xcresult failures
-> Widen to CI, matrix, or release gate only after targeted evidence is green
## Workflow, ## xcodebuild Patterns, and ## Flake Control for the baseline sequence## Resources and ## Templates for deeper materials## Related Skills for mobile QA and native-platform handoffs| Skill | Purpose |
|---|---|
| software-ios-native | Native iOS implementation, rewrites, and Xcode agent workflows |
| software-ios-runtime-debugging | Build/install/launch proof and stale-build triage before test interpretation |
| software-mobile | Platform choice and broader mobile guidance |
| qa-testing-strategy | Risk-based test strategy |
| qa-testing-mobile | Cross-platform mobile QA |
Before applying this skill on a non-trivial task, read learnings.consolidated.md in this directory (and learnings.md if present).
After applying it, if you encountered a pattern worth remembering, a mistake worth preventing, or a domain fact that surprised you, append one dated bullet to learnings.md via agents-skills-feedback-loop/scripts/append_learning.py. Do not modify SKILL.md itself.