How AI coding agents test iOS apps without local setup | Limrun
Skip to content
Limrun
← All posts

How AI coding agents test iOS apps without local setup

Limrun11 min read

An AI coding agent writes the feature in a few minutes. Then it has to answer a much harder question: does it work?

On the web, answering that is trivial. The agent starts a dev server, points a headless browser at it, and reads the DOM. All of that runs in the same Linux container the agent is already sitting in.

iOS gives it nothing. Xcode runs on macOS only, the iOS Simulator ships inside Xcode, and almost every cloud agent runs Linux. Cursor's cloud agents run on isolated Ubuntu machines. OpenAI Codex runs its cloud tasks in an Ubuntu-based container. GitHub Codespaces has no macOS image at all. So the agent can produce a few thousand lines of Swift and has no way to compile them, let alone run them.

The short answer to how agents test iOS apps in 2026: they do not test locally at all. They send the source to a remote Mac, get back a build, boot a cloud simulator, and drive the app over an API, reading the screen and the logs to decide what to do next. The agent's own machine never needs Apple software installed.

Here is what that takes and what the loop looks like in practice.

Why local setup is the bottleneck

The instinct is to fix this by installing more things in the sandbox. That path is closed. Xcode is not distributable to Linux, macOS virtual machines have licensing terms most sandbox providers will not take on, and the agent environments in wide use are Linux containers by design, because that is what makes them cheap enough to spin up per task.

Android is friendlier, since the SDK and emulator run on Linux. Even there, hardware acceleration depends on KVM being available inside the sandbox, and most agent environments do not document whether it is. Without it, the emulator either refuses to boot a standard x86 image or falls back to full CPU emulation, slow enough that the agent times out or gives up.

The workable fix is to put the macOS-only work behind an API the sandbox can call. The agent keeps doing what it is good at, and the Mac does what only a Mac can do.

What infrastructure an AI agent needs

Four pieces, in the order the agent uses them.

Remote build execution

Source has to become an installable app bundle, which means xcodebuild on a real Mac. The shape that works for agents: sync the working directory to a remote Mac, run the build there, stream logs back as they happen, and install the result on an attached simulator automatically.

Streaming logs is the part people underrate. Compiler errors are the agent's only feedback during the build phase. An agent staring at a silent process for four minutes cannot correct course, and an agent that gets errors line by line can start reasoning about the fix before the build finishes failing.

Syncing only changed bytes is worth more to an agent than to a person, because an agent will run twenty builds in the time a person runs three.

A device it can create on its own

A booted simulator the agent reaches over the network. Two properties separate infrastructure from a demo. It has to be creatable and destroyable through an API, because an agent that has to ask someone for a device is not autonomous. And each device has to be single tenant, since two agents driving one screen produce results neither can trust.

For iOS that means a real Mac running the iOS Simulator, since nothing else runs a genuine iOS runtime. For Android it means a booted emulator with an ADB tunnel, so existing tooling attaches as though the device were plugged in.

A control surface better than screenshots

A screenshot gives a model pixels and leaves it guessing what is tappable. The accessibility tree gives it structure: every element on screen with its label, accessibility identifier, type, and frame.

That difference shows up directly in reliability. An agent working from the tree knows there is a button labeled "Continue" and where it sits. An agent working from pixels has to infer it, and gets it wrong often enough to derail a run. Limrun returns both together in one call through ios-screenshot-and-element-tree, and the docs are blunt about the rule: call it before every action.

Actions then reference elements by selector rather than coordinates, which survives layout changes and device sizes.

A way to show a person the result

An agent that finishes and reports "all flows passed" is asking for trust it has not earned. Someone has to be able to check without reproducing the setup. That means a live link, a recording, or both.

One task, start to finish

Say the agent has been asked to add a forgot-password flow to an iOS app. Here is the full loop, with nothing installed locally. Every command and every output below comes from a real run against sample-agent-loop, a small public app built for exactly this walkthrough. Clone it and follow along:

git clone https://github.com/limrun-inc/sample-agent-loop && cd sample-agent-loop

1. Build on a cloud Mac.

lim xcode build . --scheme sample-agent-loop
Sync completed in 1.032s (49.3KB sent).
Building with Xcode 27.1 (27A9275)
Build Succeeded
Build completed in 11.122603s

The first run provisions a Mac sandbox, syncs the working directory, and runs xcodebuild remotely. Logs stream back. If compilation fails, the agent has real compiler output and loops on the source without ever touching a simulator.

2. Boot a device and install.

lim ios create --attach --reuse-if-exists --label agent=session-14

The attach installs and launches the build right away, and every later successful build reinstalls automatically. Labels scope the instance to this session, so a parallel task does not land on the same device.

3. Look before acting.

lim ios element-tree --json | jq -c '.. | objects | select(.AXUniqueId? != null) | {type, AXLabel, AXUniqueId, AXValue} | with_entries(select(.value != null))'

The sign-in screen, reduced to the elements the app gave identifiers:

{"type":"TextField","AXUniqueId":"signInEmailField","AXValue":"Email"}
{"type":"TextField","AXUniqueId":"signInPasswordField","AXValue":"Password"}
{"type":"Button","AXLabel":"Sign in","AXUniqueId":"signInButton"}
{"type":"Button","AXLabel":"Forgot password?","AXUniqueId":"forgotPasswordLink"}

The tree is a large payload, so filtering it before it reaches the model keeps the agent's context usable. This is the step agents skip when they are performing badly.

4. Drive the flow.

lim ios tap-element --ax-unique-id forgotPasswordLink
lim ios element-tree --json

After the tap, the form is on screen:

{"type":"Heading","AXLabel":"Forgot password"}
{"type":"StaticText","AXLabel":"Reset your password"}
{"type":"TextField","AXUniqueId":"emailField","AXValue":"Email"}
{"type":"Button","AXLabel":"Send reset link","AXUniqueId":"sendResetButton"}
lim ios set-text "test@example.com" --ax-unique-id emailField
lim ios tap-element --ax-unique-id sendResetButton
lim ios screenshot ./after-submit.png

Selectors accept --ax-unique-id, --ax-label, --ax-label-contains, --type, --title, --title-contains, and --ax-value, and they combine to narrow a match. Elements the tree can see are scrolled into view automatically.

set-text writes the value straight into the field in one call, which is what you want when the input is setup rather than the thing under test. lim ios type sends real keystrokes and is the one to use when the keyboard behavior is part of what you are testing. Once a field has focus, the keyboard shows up in the tree as rows of one-letter buttons, so filter on AXUniqueId rather than on type at that point.

When the sequence is known ahead of time, batching avoids the round trips:

lim ios perform \
  --action 'type=tapElement,selector={"AXUniqueId":"emailField"}' \
  --action "type=typeText,text=test@example.com"

5. Check underneath the UI.

The tree after submit shows the confirmation:

{"type":"TextField","AXUniqueId":"emailField","AXValue":"test@example.com"}
{"type":"StaticText","AXLabel":"Check your inbox for a reset link.","AXUniqueId":"resetConfirmation"}

That is not proof the request succeeded, so the agent pulls the app log:

lim ios app-log com.limrun.sample-agent-loop --tail 50
[password-reset] POST /password/reset failed: HTTP 422 for test@example.com body=0 bytes

The reset endpoint rejected the request while the UI cheerfully says an email is on the way. That is the interesting failure, and it is invisible in a screenshot. The agent now has something specific to fix: the view never reads the error case.

6. Fix and re-verify. The agent edits the source, runs lim xcode build . again, and because the simulator is attached, the new build installs on its own. It reruns the same flow and reads the log again.

7. Hand it to a human.

lim ios record start
# drive the happy path
lim ios record stop -o /tmp/forgot-password.mp4

Or it uploads the build and posts a preview link on the pull request:

lim xcode build . --scheme sample-agent-loop --upload agent-loop-pr-482.zip

A reviewer in your Limrun organization opens https://console.limrun.com/stream?asset=<name>&platform=ios and taps through the branch themselves.

8. Clean up.

lim ios delete
lim xcode delete

Eight steps of real work, no Mac in the agent's environment, and every step is a call the agent makes on its own.

How the agent sees what happened

Four signals, in rough order of how much the agent should trust them.

The accessibility tree. Structured truth about what is on screen. First call before any action, and again after.

App logs. lim ios app-log <bundle-id> --tail 200, or --follow to stream. This catches the class of failure where the UI renders correctly over a broken request, which is most of the failures worth catching.

Screenshots. Useful for a human reading the transcript later, and for anything visual the tree does not describe.

Recordings and live links. Every instance exposes a Signed Stream URL with its token in the URL fragment. Open it in any browser and you are watching the running device, and you can take over. That is the fastest way for a person to check on an agent mid-run, and it works for people with no development environment at all.

Wiring it up

Two decisions, and the CLI carries most of the weight.

Give the agent the CLI. It is the complete surface: builds, instance lifecycle, asset uploads, device control, testing. If your agent has a shell, this is the whole setup.

npm install --global lim
lim skills install

Run lim skills install from the project root. It fetches the latest skills from limrun-inc/skills and installs them without prompting, targeting every agent that already has a skills directory (all three when none does), every skill that fits the project, project scope. Narrow it with --agents claude|cursor|codex, --skills <name>, or --scope global.

Add MCP if the agent discovers tools rather than commands. MCP covers devices only, not builds. The organization endpoint is one command:

claude mcp add --transport http limrun https://mcp.limrun.com/mcp

Any MCP client that speaks HTTP transport works the same way.

Keep the org key out of the sandbox. LIM_API_KEY can create, list, and delete every instance you own, which is more authority than an agent in a shared sandbox should hold. Create the instance outside and hand over only that instance's credentials:

lim ios create --json > instance.json

export LIM_IOS_INSTANCE_URL=$(jq -r .status.apiUrl instance.json)
export LIM_IOS_INSTANCE_TOKEN=$(jq -r .status.token instance.json)

The sandbox never sees LIM_API_KEY, so it cannot create, list, or delete instances. It can only drive the one instance it was handed. Lifecycle stays with whoever holds the org key.

Set --inactivity-timeout as well. Agents crash, get interrupted, and lose context, and an abandoned device should reap itself rather than wait to be noticed.

FAQ

How do AI coding agents test the iOS apps they generate?

They build on a remote Mac, boot a cloud iOS simulator, install the app, then read and drive it over an API. The agent reads the accessibility tree to see what is on screen, sends taps and typing by selector, pulls app logs to catch failures the UI hides, and loops. Nothing Apple-specific runs on the agent's own machine.

What infrastructure lets an AI agent build and test mobile apps?

Four things. Remote build execution on macOS for iOS, since xcodebuild cannot run anywhere else. A simulator or emulator the agent creates and destroys through an API. A control surface richer than screenshots, which in practice means the accessibility tree plus actions by selector. And a way to show a human the result, which means a live preview link or a recording. Everything else is refinement on those four.

Can the agent run our existing test suite instead?

Yes, and most teams should. Maestro runs against a remote simulator with your flows and the Maestro CLI unmodified, aside from a few commands that do not apply remotely. Appium works through @limrun/appium-xcuitest-driver. XCTest runs through lim xcode test, which streams one line per test case and exits non-zero when anything fails. Agent-driven interaction covers the exploratory work your suite does not; it is not a reason to throw the suite away.

Does this work from CI?

Yes. A standard ubuntu-latest job installs the CLI, sets LIM_API_KEY from secrets, and builds and tests an iOS app with no macOS runner involved. Limrun also publishes ios-preview-action for the common build-and-preview case.

What makes an agent good or bad at this?

Mostly your app's accessibility labeling. An app where controls have real labels and identifiers is easy for an agent to drive on the first try. An app full of unlabeled custom controls needs accessibility work first, which is worth doing regardless of whether an agent ever touches it.

Do we still need real devices?

For release testing, yes. Simulators do not reproduce GPU behavior, thermal throttling, cellular conditions, or battery drain, and NFC, Bluetooth, and LiDAR need physical hardware. For the write-then-verify loop an agent runs dozens of times a day, simulators are faster, cheaper, and fully scriptable.

Related: Sample app: sample-agent-loop · CLI for coding agents · MCP server · Build with Xcode · Run an iOS simulator · Test with XCTest · PR previews