2026-01-30 19:41:00 +01:00
# agent-device iOS Runner
2026-03-27 15:27:56 +01:00
This folder contains the lightweight XCUITest runner used to provide element-level automation for Apple-family targets.
2026-01-30 19:41:00 +01:00
## Intent
2026-03-27 15:27:56 +01:00
2026-01-30 19:41:00 +01:00
- Provide a minimal XCTest target that exposes UI automation over a small HTTP server.
- Allow local builds via `xcodebuild` and caching for faster subsequent runs.
- Support simulator prebuilds where compatible.
## Status
2026-03-27 15:27:56 +01:00
Current internal runner for iOS, tvOS, and macOS desktop automation.
Protocol and maintenance references:
- Protocol overview: [`RUNNER_PROTOCOL.md` ](RUNNER_PROTOCOL.md )
2026-07-01 07:24:22 +02:00
- TypeScript client: [`../src/platforms/apple/core/runner/runner-client.ts` ](../src/platforms/apple/core/runner/runner-client.ts )
2026-03-27 15:27:56 +01:00
- Swift wire models: [`AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift` ](AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift )
2026-02-28 13:38:59 +01:00
## UITest Runner File Map
2026-03-27 15:27:56 +01:00
2026-02-28 13:38:59 +01:00
`AgentDeviceRunnerUITests/RunnerTests` is split into focused files to reduce context size for contributors and LLM agents.
- `RunnerTests.swift` : shared state/constants, `setUp()` , and `testCommand()` entry flow.
- `RunnerTests+Models.swift` : wire protocol models (`Command` , `Response` , snapshot payload models).
- `RunnerTests+Environment.swift` : environment and CLI argument helpers (`RunnerEnv` ).
- `RunnerTests+Transport.swift` : TCP request handling and HTTP parsing/encoding.
- `RunnerTests+CommandExecution.swift` : command dispatch (`execute*` ) and command switch.
- `RunnerTests+Lifecycle.swift` : activation/retry/stabilization and recording lifecycle helpers.
2026-04-01 20:34:56 +02:00
- `RunnerTests+Interaction.swift` : tap/drag/swipe/type/back/home/rotate/app-switcher helpers.
2026-02-28 13:38:59 +01:00
- `RunnerTests+Snapshot.swift` : fast/raw snapshot builders and include/filter helpers.
- `RunnerTests+SystemModal.swift` : SpringBoard/system modal detection and modal snapshot shaping.
- `RunnerTests+ScreenRecorder.swift` : nested `ScreenRecorder` implementation.
2026-03-27 15:27:56 +01:00
2026-06-06 21:26:12 +02:00
## Snapshot Strategy
2026-06-12 17:32:56 +02:00
iOS snapshots have two explicit public capture modes:
2026-06-06 21:26:12 +02:00
- full/raw snapshots use recursive XCTest snapshots for rich hierarchy and diagnostics;
2026-06-12 17:32:56 +02:00
- interactive snapshots filter the same visible tree down to agent-facing refs.
2026-06-06 21:26:12 +02:00
Some simulator apps expose accessibility trees that lower-level AX services can inspect but XCTest
2026-06-12 17:32:56 +02:00
cannot serialize reliably. In those cases interactive snapshots may return a sparse root quickly,
while full snapshots preserve the XCTest error. See
2026-06-06 21:26:12 +02:00
[`../docs/adr/0004-ios-snapshot-backend-strategy.md` ](../docs/adr/0004-ios-snapshot-backend-strategy.md )
2026-06-12 17:32:56 +02:00
for the backend boundary and future simulator AX-service direction.
2026-06-06 21:26:12 +02:00
2026-03-27 15:27:56 +01:00
## Protocol Notes
- The daemon posts JSON commands to `POST /command` on the runner's local HTTP listener.
- The runner responds with a JSON envelope shaped as `{ ok, data?, error? }` .
- The protocol is internal to `agent-device` ; when adding or renaming commands, update both wire models and the protocol tests/docs in the same change.