r/iOSProgramming • • 3h ago

Discussion Let Claude Code test your iOS app once on the Simulator or a real iPhone, then replay it in CI forever with zero tokens (open source, 3x faster than agent-device)

I built phonedriver, a free open-source tool (Rust + a tiny Objective-C XCTest runner, zero telemetry) that lets Claude Code, Codex, Cursor, or plain scripts test iOS apps on the Simulator or a real iPhone (and android) over USB or Wi-Fi.

Instead of feeding screenshots on every turn or writing flaky XCTest UI code by hand, phonedriver sends the model a short numbered text list of the screen (59 tokens for a sign-in view) and returns only the lines that changed after each tap (20 tokens). Once an agent tests a flow and it passes, you save it and replay it in CI with no model at all:

phonedriver save login.steps
phonedriver replay login.steps --screens screens/login

On simulator-use's iOS Simulator sign-in benchmark (time and reply tokens):

Stepphonedriversimulator-useagent-device
Read screen29 ms (59 tok)45 ms (71 tok)33 ms (125 tok)
Tap + settle316 ms (20 tok)435 ms (17 tok)872 ms (38 tok)
Type email848 ms (13 tok)578 ms (14 tok)2.43 s (47 tok)
Full sign-in (step by step)1.75 s (173 tok)1.78 s (192 tok)5.67 s (762 tok)
MCP tool list (paid every turn)17 tools (1,849 tok)12 tools (2,443 tok)63 tools (27,918 tok)

Four Xcode and Simulator quirks that got it there:

  • XCTest spends ~330 ms before the app sees a tap. Sending Simulator taps straight through SimulatorKit's HID port (the path idb uses) delivered the touch in a few milliseconds, dropping tap-and-settle from 0.84 s to 0.32 s.

  • HID typing is fast and silently wrong. Sixteen characters went in under 10 ms, but x "q" 'r' -- teh ok. [email protected] came out as x ‘q’ ‘r’ — teh ok. gary2mail.com because apps dropped Shift and applied smart punctuation when the hardware keyboard was off. Typing stays on XCTest instead (simulator-use beats phonedriver on Simulator typing because hardware keys hide the software keyboard, while XCTest keeps it up like a real iPhone).

  • Xcode recorded QuickTime video of every runner session. Long-running UI tests default to PreferredScreenCaptureFormat = screenRecording. My Simulator's testmanagerd folder held 154 movies up to 209 MB each (1.2 GB total), and 84 DerivedData folders took another 940 MB. Setting systemAttachmentLifetime = keepNever and preferredScreenCaptureFormat = screenshots in the scheme's test action stopped it.

  • Fast accessibility reads without WebDriverAgent. Calling XCAXClient_iOS directly read an iPhone 17 Simulator screen in 22 ms vs 380 ms for WDA at depth 30 (45 ms with every WDA option tuned).

Install in one line: brew install hridaya423/tap/phonedriver or npx -y phonedriver init

Site: https://phonedriver.dev
Repo: https://github.com/hridaya423/phonedriver
Benchmarks & raw runs (including the steps I lose): https://phonedriver.dev/benchmarks/#simulator

If you run long Xcode UI test suites, check your Simulator's testmanagerd folder. Mine was quietly holding over a gigabyte of .mov files too lol

27 Upvotes

5 comments sorted by

2

u/Klorkin9 Swift 2h ago

This is fire! testing now

1

u/Puzzled-Stick9170 2h ago

lmk how it goes! :)

2

u/svangsgaard 2h ago

Fantastic idea. Going to try this on my apps.

1

u/Puzzled-Stick9170 2h ago

thanks! lmk how it goes for you

2

u/lncredible-dev 2h ago

The testmanagerd tip alone was worth the read. How does a saved replay handle a small UI change, like a button label getting reworded? Does the step fail outright, or can it fall back to the agent just for that one step?