diff --git a/docs/integration/ci-appium.mdx b/docs/integration/ci-appium.mdx index 26dbe55..e7eab52 100644 --- a/docs/integration/ci-appium.mdx +++ b/docs/integration/ci-appium.mdx @@ -25,6 +25,7 @@ The CI scripts are under `scripts/ci/` and the WebDriverIO specs under `e2e/` in - Set `simulatorStartupTimeout` to 300 seconds or more, and set the WebDriverAgent and session timeouts above the three to five minutes a cold WebDriverAgent build takes. - Run `xcrun simctl list` once before the run. - After `/status` is ready, prefetch the Metro bundle. Prebuild WebDriverAgent once under `artifacts/e2e/wda-derived-data` and pass it to the driver with `usePrebuiltWDA` and `derivedDataPath`. Do not put `DerivedData` in `e2e/node_modules`. +- WDA prebuild sets the simulator deployment target to 15.1 so vendored WebDriverAgent builds on current Xcode simulator SDKs (Xcode 26 and 27). - Do not use `usePreinstalledWDA` on a simulator. It launches the `.xctrunner` app with plain `simctl`, which exits at `domain:dyld(6) code:1` because `simctl` never injects the XCTest frameworks. Appium then polls `127.0.0.1:8100/status` until `wdaLaunchTimeout`. A readiness watchdog, `IOS_WDA_READY_DEADLINE` with a default of 180 seconds, aborts the attempt when the port is dead. - Use two or three serialized outer WebDriverIO attempts with `connectionRetryCount: 0`. Between attempts, delete sessions, terminate and reinstall the app, stop Appium, clear the Appium and WebDriverAgent ports, and reuse the prebuilt WebDriverAgent. Never overlap `POST /session`. - Keep `noReset: false`, `enforceAppInstall: true`, and `forceAppLaunch: true`, and do not launch the app with `simctl launch` first. diff --git a/scripts/ci/run-ios-e2e-cell.sh b/scripts/ci/run-ios-e2e-cell.sh index 0ee55ff..e7c1364 100755 --- a/scripts/ci/run-ios-e2e-cell.sh +++ b/scripts/ci/run-ios-e2e-cell.sh @@ -7,6 +7,7 @@ # IOS_DEVICE_NAME (default iPhone 17) # SKIP_BUILD=1 SKIP_METRO=1 SKIP_APPIUM_INSTALL=1 # METRO_PORT / APPIUM_PORT (defaults: Metro 8081 both cells; Appium 4723 dynamic / 4725 static) +# WDA_IPHONEOS_DEPLOYMENT_TARGET (default 15.1; always passed to the WDA xcodebuild) set -euo pipefail ROOT="$(cd "$(dirname "$0")/../.." && pwd)" @@ -31,6 +32,9 @@ fi export APPIUM_PORT export APPIUM_HOST="${APPIUM_HOST:-127.0.0.1}" WDA_PORT="${WDA_PORT:-8100}" +# Vendored appium-webdriveragent still defaults to 12.0, which current +# simulator SDKs reject. Always pass an explicit target (override via env). +WDA_IPHONEOS_DEPLOYMENT_TARGET="${WDA_IPHONEOS_DEPLOYMENT_TARGET:-15.1}" IOS_E2E_ATTEMPTS="${IOS_E2E_ATTEMPTS:-3}" WDA_DERIVED="$REPORT_DIR/wda-derived-data" mkdir -p "$WDA_DERIVED" @@ -349,6 +353,7 @@ run_logged "$LOG_DIR/wda-xcodebuild.log" xcodebuild \ -destination "generic/platform=iOS Simulator" \ -derivedDataPath "$WDA_DERIVED" \ CODE_SIGNING_ALLOWED=NO \ + IPHONEOS_DEPLOYMENT_TARGET="${WDA_IPHONEOS_DEPLOYMENT_TARGET}" \ build-for-testing export IOS_WDA_DERIVED_DATA_PATH="$WDA_DERIVED" export IOS_WDA_APP_PATH="$WDA_DERIVED/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app" diff --git a/src/__tests__/wda-deployment-target.test.ts b/src/__tests__/wda-deployment-target.test.ts new file mode 100644 index 0000000..6f4b5e9 --- /dev/null +++ b/src/__tests__/wda-deployment-target.test.ts @@ -0,0 +1,52 @@ +import fs from 'node:fs'; +import path from 'node:path'; + +/** + * The WDA prebuild must pass IPHONEOS_DEPLOYMENT_TARGET explicitly. + * Vendored appium-webdriveragent still defaults the project to 12.0, which + * current Xcode simulator SDKs reject. This reads the cell script only. + */ +describe('scripts/ci/run-ios-e2e-cell.sh WDA deployment target', () => { + const scriptPath = path.join( + __dirname, + '../../scripts/ci/run-ios-e2e-cell.sh' + ); + const source = fs.readFileSync(scriptPath, 'utf8'); + + function wdaBuildInvocation(): string { + const start = source.indexOf( + 'run_logged "$LOG_DIR/wda-xcodebuild.log" xcodebuild' + ); + expect(start).toBeGreaterThanOrEqual(0); + const rest = source.slice(start); + const matched = rest.match(/^[\s\S]*?\n[ \t]*build-for-testing\b/); + expect(matched).not.toBeNull(); + return (matched?.[0] ?? '') + .replace(/#[^\n]*/g, '') + .replace(/\/\*[\s\S]*?\*\//g, ''); + } + + it('defaults WDA_IPHONEOS_DEPLOYMENT_TARGET to 15.1 before the WDA build', () => { + const assignment = + 'WDA_IPHONEOS_DEPLOYMENT_TARGET="${WDA_IPHONEOS_DEPLOYMENT_TARGET:-15.1}"'; + const assignmentAt = source.indexOf(assignment); + const invocationAt = source.indexOf( + 'run_logged "$LOG_DIR/wda-xcodebuild.log" xcodebuild' + ); + expect(assignmentAt).toBeGreaterThanOrEqual(0); + expect(invocationAt).toBeGreaterThan(assignmentAt); + }); + + it('passes IPHONEOS_DEPLOYMENT_TARGET on the WebDriverAgentRunner build-for-testing invocation', () => { + const invocation = wdaBuildInvocation(); + expect(invocation).toMatch(/-scheme WebDriverAgentRunner/); + expect(invocation).toMatch( + /-destination "generic\/platform=iOS Simulator"/ + ); + expect(invocation).toMatch(/build-for-testing/); + expect(invocation).toMatch( + /IPHONEOS_DEPLOYMENT_TARGET="\$\{WDA_IPHONEOS_DEPLOYMENT_TARGET\}"/ + ); + expect(invocation).not.toMatch(/IPHONEOS_DEPLOYMENT_TARGET=12\.0/); + }); +});