DEV Community

Priya Negi
Priya Negi

Posted on

I automated my iPhone using this AI agent

I automated my iPhone using this AI

I've always envied Android people. Plug in a phone, run a couple of ADB commands, and you've got a bot tapping around your device in minutes. iOS never let me have that. Apple's sandboxing means there's no official way to remotely drive a physical iPhone — so for a long time, "automate my iPhone" just wasn't a sentence I could act on.

That changed when I found Mobilerun. It lets you connect your own iPhone to the cloud and hand it over to AI agents that tap, type, and navigate apps like a real person would, end to end. I decided to set it up on my own phone and see how far I could get. Here's how it went.

What I needed before starting

Before touching any code, I made sure I had:

  • A Mobilerun account with a Personal Phone subscription
  • A Mac with Xcode installed
  • My iPhone, connected via USB
  • An Apple ID with signing capability (a free personal team works fine)

One thing worth knowing upfront: with a free Apple ID, builds expire after 7 days, so you'll need to rebuild and re-trust periodically, and you can only sign for 3 devices at a time. A paid Apple Developer account ($99/year) removes both limits. I started with my free Apple ID just to test the waters.

How this actually works under the hood

Mobilerun controls the iPhone through WebDriverAgent (WDA), an open-source project that exposes input injection and screenshots on iOS. Mobilerun maintains its own fork of it, tuned for higher-quality streaming, lower-latency accessibility tree fetching, and faster touch input. The idea is simple: I build WDA onto my iPhone once with Xcode, and then a CLI tool called mobilerun-ios opens a WebSocket connection to Mobilerun's cloud and keeps my device online.

Once I understood that, the rest of the setup made a lot more sense. Here's exactly what I did.

Step 1: Turning on Developer Mode

Developer Mode is what lets Xcode install and launch development builds on the iPhone. I went to Settings → Privacy & Security → Developer Mode, toggled it on, and restarted the phone when prompted. After reboot, I confirmed the change and I was set.

One gotcha: if you don't see the Developer Mode entry at all, it's because your iPhone hasn't been connected to a Mac running Xcode yet. Plug it in, open Xcode once, and the option should appear.

Step 2: Configuring the iPhone to stay connected

A Personal Phone is meant to stay online for hours or even days, so I had to change three settings that make the difference between a connection that survives and one that needs constant babysitting.

First, I disabled Auto-Lock. If the iPhone locks, the screen goes black and the session drops offline — so I set Settings → Display & Brightness → Auto-Lock to Never.

Second, I turned on automatic time zone under Settings → General → Date & Time → Set Automatically. This keeps the device's time zone in sync with its simulated location; setting it manually just doesn't work on non-jailbroken devices.

Third — and this one I thought hard about — I removed the passcode. WDA's host session occasionally crashes or expires, and Mobilerun restarts it automatically, but only if there's no passcode in the way. Otherwise the relaunched session lands on the lock screen and just sits there until someone manually unlocks it. Since I wanted this phone to run unattended, I turned off the passcode under Settings → Face ID & Passcode → Turn Passcode Off.

I want to flag this clearly: removing the passcode disables Face ID, Apple Pay, and some iCloud features. I used a dedicated automation phone for this, not my daily driver, and I'd recommend the same to anyone trying this.

Step 3: Building and installing WebDriverAgent

This was, by far, the trickiest part of the whole process — and most connection problems I hit later traced straight back to signing or trust issues here. I took it slow.

I cloned Mobilerun's WDA fork:

git clone --branch v1.1.0 https://github.com/droidrun/WebDriverAgent
Enter fullscreen mode Exit fullscreen mode

(The upstream Appium WebDriverAgent also works, but with higher latency and lower streaming FPS, so I stuck with Mobilerun's fork.)

Then I:

  1. Opened WebDriverAgent.xcodeproj in Xcode
  2. Selected my connected iPhone as the run destination
  3. Chose the WebDriverAgentRunner scheme
  4. For both the WebDriverAgentRunner and WebDriverAgentBroadcast targets, opened Signing & Capabilities, ticked Automatically manage signing, and picked my Apple ID / Team (WebDriverAgentBroadcast is the extension that enables high-FPS screen streaming — skipping it fails the build, so don't skip it)
  5. Pressed Cmd+U to build-for-testing
  6. On the iPhone, trusted the certificate under Settings → General → VPN & Device Management → tapped my team → Trust

I ran into both of the classic snags here. First, "Failed to register bundle identifier" — bundle IDs have to be unique per Apple ID, so I appended a suffix to the runner's ID (like com.facebook.WebDriverAgentRunner.) and mirrored it in the extension as com.facebook.WebDriverAgentRunner..xctrunner.broadcast. Second, "Could not launch WebDriverAgentRunner" on my first Cmd+U — this just meant the certificate wasn't trusted yet. I trusted it on the device and pressed Cmd+U again, and it went through.

Step 4: Installing the mobilerun-ios CLI

With WDA built, I installed the CLI. Homebrew was the easiest route for me:

brew install droidrun/tap/mobilerun-ios
Enter fullscreen mode Exit fullscreen mode

There's also a curl install if you'd rather skip Homebrew:

curl -fsSL https://media.mobilerun.ai/releases/mobilerun-ios/install.sh | sh
Enter fullscreen mode Exit fullscreen mode

I confirmed it installed correctly with:

mobilerun-ios --version
Enter fullscreen mode Exit fullscreen mode

Step 5: Logging in

Next:

mobilerun-ios login
Enter fullscreen mode Exit fullscreen mode

The CLI printed a short code and opened a verification page in my browser. I approved it there, then confirmed everything worked with mobilerun-ios whoami.

If you're setting this up in CI or a headless environment, you can skip the browser flow entirely and use an API key instead:

export MOBILERUN_IOS_TOKEN=dr_sk_your_api_key
Enter fullscreen mode Exit fullscreen mode

Step 6: Connecting the iPhone

With my iPhone plugged in and unlocked, I listed available devices:

mobilerun-ios list
Enter fullscreen mode Exit fullscreen mode

Which showed something like:

UDID                                      NAME             TYPE    OS     STATE    PORTAL
00008020-001A2B3C4D5E6F70                 My iPhone        real    18.2   ready    —
Enter fullscreen mode Exit fullscreen mode

I copied the UDID and started the connection:

mobilerun-ios 00008020-001A2B3C4D5E6F70
Enter fullscreen mode Exit fullscreen mode

Leaving the UDID off would connect every attached iPhone instead. The command keeps the device online for as long as it keeps running — Ctrl+C ends the session. For a setup I wanted to leave running in the background, I used the detach flag instead:

mobilerun-ios -d 00008020-001A2B3C4D5E6F70
Enter fullscreen mode Exit fullscreen mode

This printed a PID and a log path, then exited cleanly. I could stop it later with mobilerun-ios stop.

Step 7: Running my first task

I opened the Devices page in the Mobilerun dashboard, and there it was — my iPhone, showing up as a connected Personal Phone. From there I went into the Playground, selected my device, and kicked off a task to confirm everything worked end to end. It did. My iPhone was now something an AI agent could actually drive, from anywhere.

Problems I hit (and how I fixed them)

A few things tripped me up along the way, so I'm listing them here in case they help:

WebDriverAgentRunner crashing on launch usually meant I needed to re-sign the runner target in Xcode and confirm the certificate was trusted before hitting Cmd+U again.

When mobilerun-ios list showed no devices, it was almost always one of three things: the cable was charge-only instead of a proper data cable, the iPhone was locked, or I hadn't accepted the "Trust This Computer" prompt.

Auth failures were solved by re-running mobilerun-ios login, or, for API keys, double-checking that MOBILERUN_IOS_TOKEN was actually exported in the same shell I was working in.

If the screen went black mid-session, it was Auto-Lock creeping back on — setting it back to Never fixed it every time.

And if the connection dropped after several hours and the device just sat on the lock screen, it meant the WDA session had restarted but a passcode was blocking it. Unlocking manually solved it in the moment; removing the passcode solved it for good on an unattended setup.

One more thing worth knowing: dumping TikTok's accessibility tree times out and crashes the automation session, so I've been avoiding TikTok tasks for now.

What I took away from this

Going from a stock iPhone to a cloud-connected automation device took Developer Mode, one Xcode build of WebDriverAgent, and a single CLI command. The Xcode signing step ate up the most time and patience, but it's a one-time cost — or a once-a-week one, if you're running on a free Apple ID like I was.

If you want to go deeper, Mobilerun's full documentation on connecting an iPhone is here: docs.mobilerun.ai/guides/connect-iphone

Top comments (0)