environment-setup-xcuitest
Set up and validate an XCUITest Appium environment on macOS
Skill body
appium-xcuitest-environment-setup
Goal
Prepares a stable Appium XCUITest execution environment on macOS by validating Node.js and Appium installation, installing and validating Xcode toolchains, and iterating Appium doctor checks until doctor reports 0 required fixes needed.
Decision Logic
- If host OS is not macOS: stop and tell the user this skill only supports macOS.
- If Xcode is missing or command line tools are unconfigured: install/configure them before continuing.
- If current Node.js does not satisfy
engines.nodefor bothappiumandappium-xcuitest-driver: install/upgrade Node.js to a compatible active LTS version. - If Appium CLI or
xcuitestdriver is missing: install them via Appium CLI. - Use global npm/Appium commands by default (
npm install -g appium,appium ...). - Use local Appium commands (
npx appium ...) only when the user explicitly requests local execution. - If the user explicitly requests media features that require FFmpeg: run
environment-setup-ffmpegbefore final validation. - If install returns “already installed”, ignore the error and continue (or run driver update).
- If
appium driver doctor xcuitestreports missing dependencies: fix each reported dependency and re-run doctor.
Instructions
- Prepare Node.js + npm environment on macOS
sw_vers node -v npm -vIf
nodeis missing, install a compatible active LTS release and re-run the commands. - Install Appium npm command and XCUITest driver
npm install -g appium appium driver install xcuitest || appium driver update xcuitest appium driver list --installed --json || appium driver list --installedPrefer
--jsonoutput for machine-readable verification. Confirm anxcuitestkey is present; only fallback to plain-text output when--jsonis unsupported. If the install command fails only becausexcuitestis already installed, continue and do not stop preparation. - Validate Appium npm commands and Node compatibility (after driver setup)
appium -v appium driver list --installed --json || appium driver list --installed npm view appium engines --json npm view appium-xcuitest-driver engines --jsonIf current Node.js does not satisfy the reported
engines.noderanges, install/upgrade Node.js to a compatible active LTS version and re-run the setup checks. - Verify Xcode command line setup and license
First validate Xcode availability:
xcodebuild -versionIf version info is returned, continue without changing
xcode-select. If version info is not returned, check the selected developer path:xcode-select -pIf the selected path does not contain
Contents/Developer, try setting it to the default Xcode app path:xcode-select --switch /Applications/Xcode.app/Contents/DeveloperRe-validate:
xcodebuild -version xcode-select -pThen ensure license and first-launch tasks are complete (use privilege escalation only if prompted/required):
sudo xcodebuild -license accept xcodebuild -runFirstLaunch - Optional helper tools
Install additional iOS helper tools only if the user explicitly requests capabilities that require them.
- For FFmpeg-related capabilities, run
environment-setup-ffmpeg.
- For FFmpeg-related capabilities, run
- Run Appium doctor for XCUITest and fix in a loop
appium driver doctor xcuitestUse
0 required fixes neededas the pass/fail gate. Optional warnings are non-blocking. Resolve required fixes, then re-run until this gate is met. For deterministic automation, parse the doctor output for that exact phrase instead of relying on visual formatting.applesimutilswarnings are optional for basic simulator session creation, but recommended when you need permission-management helper APIs. Bash gate example:DOCTOR_OUT="$(appium driver doctor xcuitest 2>&1)" echo "$DOCTOR_OUT" | grep -q "0 required fixes needed" || { echo "$DOCTOR_OUT"; exit 1; } echo "$DOCTOR_OUT" | grep -E "0 required fixes needed|optional fix"PowerShell gate example:
$doctorOut = appium driver doctor xcuitest 2>&1 | Out-String if ($doctorOut -notmatch '0 required fixes needed') { throw "Doctor required fixes remain" } $doctorOut | Select-String '0 required fixes needed|optional fix'AI-assisted fallback (only if exact phrase matching is inconclusive due output-format changes):
- Re-run doctor once and capture full output (
appium driver doctor xcuitest 2>&1 | tee /tmp/appium-doctor-xcuitest.log). - Ask an AI agent to classify required vs optional findings from the captured output.
- Accept a pass only when the output clearly indicates zero required issues (for example: no required-fix section and no required-check failures).
- If still ambiguous, mark status as
needs-manual-reviewand do not mark the skill complete.
- Re-run doctor once and capture full output (
- Optional simulator readiness preflight
Before smoke testing, you may verify simulator availability to reduce false failures in session creation:
xcrun simctl list devicesIf required by your flow, boot a target simulator before session creation.
- Start Appium server smoke test
appium serverKeep this server process running in Terminal A. In Terminal B, run:
curl -s http://127.0.0.1:4723/statusFirst confirm
/statusresponds successfully fromcurl. Then confirm readiness from server logs and ensure theAvailable drivers:block containsxcuitest(for example:- [email protected] (automationName 'XCUITest')). If startup banner logs are not available in your terminal integration, use this fallback verification path:appium driver list --installed --jsonincludesxcuitest/statusreports server readiness After smoke validation, clean up the running Appium server:- In Terminal A, stop the server with
Ctrl+C. - Verify no leftover Appium server process (Terminal B):
pgrep -fl "appium.*server" || echo "no appium server process"
- Agent completion criteria
Mark the skill complete only when all are true:
appium driver list --installed --jsonincludesxcuitest(fallback toappium driver list --installedif--jsonis unsupported)appium -vsucceedsappium driver doctor xcuitestreports0 required fixes needed(optional warnings are allowed)- task result includes the doctor summary line with required/optional fix counts
curl -s http://127.0.0.1:4723/statusreturns a successful status response- Appium server logs show startup/readiness successfully after the curl check, or (if banner logs are unavailable) readiness is confirmed by
/statusplus JSON driver listing that includesxcuitest - If logs are available,
Available drivers:includes anxcuitestentry - Appium smoke-test server process is cleanly stopped after validation
Constraints
- This skill is macOS-only; do not provide Linux/Windows alternatives.
- Use global npm/Appium commands as the default execution mode.
- Use
npx appiumonly if the user explicitly asks for local execution. - Always re-run
appium driver doctor xcuitestafter every fix. - Treat optional doctor warnings as non-blocking.
- Ask the user before installing optional dependencies, and install them only when explicitly needed.
- Do not skip Xcode license and first-launch checks.
- If privileged commands are required, pause and provide the exact command for user execution.
- Do not report readiness until doctor and smoke tests pass.