r/iOSProgramming • u/Puzzled-Stick9170 • 7d 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):
| Step | phonedriver | simulator-use | agent-device |
|---|---|---|---|
| Read screen | 29 ms (59 tok) | 45 ms (71 tok) | 33 ms (125 tok) |
| Tap + settle | 316 ms (20 tok) | 435 ms (17 tok) | 872 ms (38 tok) |
| Type email | 848 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
idbuses) 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. Gary@Mail.comcame out asx ‘q’ ‘r’ — teh ok. gary2mail.combecause apps dropped Shift and applied smart punctuation when the hardware keyboard was off. Typing stays on XCTest instead (simulator-usebeats 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'stestmanagerdfolder held 154 movies up to 209 MB each (1.2 GB total), and 84DerivedDatafolders took another 940 MB. SettingsystemAttachmentLifetime = keepNeverandpreferredScreenCaptureFormat = screenshotsin the scheme's test action stopped it. - Fast accessibility reads without WebDriverAgent. Calling
XCAXClient_iOSdirectly 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
6
u/Klorkin9 Swift 7d ago
This is fire! testing now
2
u/svangsgaard 7d ago
Fantastic idea. Going to try this on my apps.
2
u/ThierryBuc 6d ago
Really nice website!
Will test it out
2
u/walkccc 5d ago
Fantastic. Ty for sharing!
2
u/blazejkustra 5d ago
I work on Argent (Software Mansion) so I'm biased, but if your agent needs to do more than tap through screens, give it a shot!!
Same idea of "agent tests it once, CI replays it with no tokens", plus the agent can actually debug what went wrong: network, logs, native profiling. It can also run a bunch of agents on separate sims in parallel as well
https://argent.swmansion.com/
4
u/lncredible-dev 7d 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?
3
u/mikerCZX 5d ago
Nice work, and the testmanagerd tip is genuinely useful. I looked through the repo and approach for our case, and it's not a fit for us. I haven't run it, so this is an assessment of the approach, not a test result.
Most of what we catch in UI testing is visual: clipped text and overlaps at the largest Dynamic Type sizes, and layouts that stretch badly on iPad. A numbered text list of the accessibility tree can't show any of that, because the element is "there" and reads fine while it's drawn wrong.
Replay is the other part. A saved .steps file is a test someone has to maintain, and with ~30 localizations a renamed label breaks it in every language. Zero tokens in CI is great, but we'd pay for it in upkeep.
If your target is functional flows (sign-in, navigation, "does this screen respond"), the token numbers look really good. It just doesn't cover the layout and rendering bugs that bite us most.
2
u/DayEnvironmental3454 6d ago
Nice work. One thing I'd watch with agent-driven simulator runs: if each run boots a fresh simulator or clones one, those devices pile up fast, and each one carries its own data and caches. Does phonedriver reuse a single booted device, or create one per run? If it's per run, a `xcrun simctl delete` on teardown (or `xcrun simctl delete unavailable` in CI) keeps it from eating the disk over a few weeks.
1
u/Ok_Breakfast_9531 6d ago
the testmanagerd thing is a great find, going to check mine tonight. question about the real iphone over wifi path: is that going through the same coredevice tunnel xcode uses, or something of your own? asking because my phone on a wifi 7 router was basically invisible on the 5ghz band and only showed up once it was on 2.4ghz, and i never fully figured out which side was dropping it. curious whether phonedriver hits the same thing or falls back to usb when it can't find the device
1
u/Beautiful_Pickle_712 1d ago
I don’t develop mobile app but the landing page is awesome!