---
title: "Claude Code and the iOS Simulator: what breaks"
slug: claude-code-and-the-ios-simulator-what-breaks
section: tech
date: 2026-10-20T14:12:00.000Z
canonical: https://roland.leth.ro/blog/tech/claude-code-and-the-ios-simulator-what-breaks
description: "Claude Code drives the iOS Simulator from the desktop app, with no MCP or skill. What broke in daily use: the sandbox, xcodebuild’s errors and dead captures."
---

Claude Code can drive the iOS Simulator without any MCP server, skill or plugin, as long as you use the Claude desktop app (and maybe the CLI, but I haven't tried). You have to first attach it, then you'll get a system approval request (for each attach) explaining what will happen and the privacy concerns. 

Its [iOS Simulator pane][1] (in beta) opens next to the conversation when Claude launches your app. From there, Claude installs it, taps through it and takes screenshots to check its own work, while you watch or tap along. From the CLI, according to the same docs, it goes through computer use instead.

Beside the pane, my sessions call `xcodebuild` for builds and tests and `xcrun simctl` for devices, straight through Bash. With those, Claude can build, run and check an iOS app on its own, as long as you plan for how the simulator and `xcodebuild` fail — and they fail quite often, usually looking like a different problem.

Everything below comes from the [running journal my sessions keep][2] on 2 of my apps, [Digest][3] (not out yet) and [Reckon][4]. It’s a few months of failures, which is probably more than you’ll hit, but most of them are pretty easy to plan for once you know what they look like.

I started with the agent in Xcode 26, on [Continuum][5], and eventually fully moved to Claude Code there. Why? Initially for the size of the pane, but ultimately for the [skills, rules and hooks][6]; Xcode is much more limited as well, even though better integrated. Starting with Xcode 27 this should have been somewhat improved, but I haven't checked, so I can't really say.

## The sandbox and bare commands

If you run Claude Code with [its sandbox][6] on, `xcodebuild` and `simctl` can’t do much inside it. They need to reach CoreSimulatorService (the background service that runs the simulators) and to write to places like the system’s temp folder, and the sandbox allows neither, which is why I have them in `sandbox.excludedCommands`, the list of commands allowed to run outside it.

The catch is in [the docs][7], but I learned it the hard way: a call only leaves the sandbox when _every_ command in it matches, and a redirect to a file keeps the whole call inside. For example, `xcodebuild … > build.log 2>&1` is sandboxed, and even anything chained with `&&` or `;`, only bare commands get out (at least that was my experience, maybe I was doing something wrong).

The failure doesn’t mention the sandbox at all, though. It says “CoreSimulatorService connection became invalid”, then “Unable to find a device matching the provided destination specifier” or other obscure errors, then exits with 70.

That reads like a wrong simulator name, so the first thing Claude (or you) will likely try is another device, which will change nothing.

Why redirect at all, then? Builds ran in the background as `xcodebuild … > log 2>&1; echo "build=$?"`, so Claude could read the log and the exit code afterwards. Except the exit code was the `echo`’s, always 0 (and in fish, which is my shell, `$?` isn’t the exit status at all; `$status` is), so one August build came back green with `BUILD FAILED` in its log, and it happened again on at least 3 other days. That’s pretty much [reported success nobody verified][8], just smaller.

What runs now is just the bare command, in the background:

```bash
xcodebuild test -project Digest.xcodeproj -scheme Digest -destination 'platform=iOS Simulator,name=iPhone 17 Pro Max,OS=27.0'
```

A background task in Claude Code writes its output to its own file, which Claude reads once the run finishes, and the completion notification carries `xcodebuild`’s real exit code.

Running bare also retired the idea of a dedicated log file, which had its own incident: two sessions running at the same time, writing to the same file would overwrite each other.

A hook now denies `xcodebuild` with anything redirected or chained after it. `git commit` has the same bare-only rule, and a chained one fails as a GPG error instead; I wrote about that one in [the post on rules, hooks and skills][6].

## “Unable to find a device”

That error turned out to have at least 3 causes, and the device was the _actual_ problem in only one of them:

- The sandbox, as above. The lines before it mention the connection to CoreSimulatorService, and further down there were denied writes to the temp folder. The fix was the command line, not the destination.
- A destination with `name=` and no `OS=`, which lets `xcodebuild` pick the latest iOS it knows, a runtime that might not have a simulator at all. Pass both, and if in doubt, `xcrun simctl list devices available` shows what actually exists.
- CoreSimulatorService getting stuck: installs timing out after 120 seconds, boots failing, then the same error. Restarting the service fixed it. That one I did by hand.

When Claude says it can’t find a device, you’ll probably want to look at the command line first, then at the destination, and only then at the device.

## Test output through `xcodebuild`

`xcodebuild` doesn’t show Swift Testing’s assertion messages, and it doesn’t show `print()` either, so a test can’t just print a table for Claude to read. Digest’s probes (tests that measure something instead of asserting it) write theirs to a file the session can read, which is part of [a separate post][9].

`-only-testing` cost more runs than that. Swift Testing names a test with its parentheses, `someTest()`, so a filter ending in `someTest` matches nothing, runs zero tests and prints `TEST SUCCEEDED`. That happened on at least 5 different days, in sessions that _already had_ a note about it in memory. [Rules can go stale][6], but this one never did, it was right the whole time and still got skipped; a note is something Claude might read, not something that checks.

What catches it is the test’s own line in the output, `Test case 'Suite/someTest()' passed`, and for a probe, its file: if the file isn’t there, nothing ran.

Once, it went the other way. The same 2 tests failed across 5 runs on 2 simulators, while every check of their logic said they should pass. An enum’s payload had changed and the incremental build had produced a broken bundle; a forced full recompile went green and stayed green, after about half a session spent debugging tests that were fine.

Some of the above sound very obvious and in hindsight, they are. But at the time, everything was a black box and I learned it by hitting various walls.

## The simulator itself

The screen capture is probably what broke most. A test run reboots the device it runs on, and when that was the device under the pane, the capture was gone for the rest of the session. Attaching it again from the pane’s own picker brought it back once; the second time it didn’t, and I checked those screens by eye.

On [Reckon][4], the capture died during an App Store screenshot export, and Claude just carried on blind, tapping coordinates it had seen earlier and checking the exported PNGs instead (the exporter has [a post of its own][10]), so it can continue, it's just weird to not have the pane be “live”.

Name the device on every call, too.

The docs say each device belongs to the session that launched it, but a screenshot call without a device went to “the attached or first booted simulator”, which was another session’s iPad running the same app. Nothing got tapped, but a tap would have gone to the same place, maybe breaking what the other session was doing.

It wasn’t the only time one session reached into another, either: a `detach` naming one device detached every pane, other sessions’ included, and an `xcodebuild` run aimed at `name=iPhone 18 Pro,OS=27.0` landed on a device another session had created. Each session now creates its own device with `xcrun simctl create` and names it in every call, and the device list fills up with things like “Claude orphaned focus tests” and “Claude sentence case 27.0” until [the wrap-up][6] deletes them.

Each new device also needs my one-time “Let Claude use it”, so replacing a worn one means I have to be around, but it's a small price to pay and it doesn't happen _that_ often either.

White screens also happened quite regularly. Is it the app's fault or the capture? Sometimes it’s the capture, stuck on the launch frame while the app runs fine underneath. Sometimes the white is _real_, which `xcrun simctl io <device> screenshot` settles: if it shows the same frame, it’s the app.

And sometimes it’s just slow. On a freshly created device, with the Mac under load, 2 launches sat white for over 3 minutes and looked hung, and the next one drew its first frame after about 90 seconds. Before calling anything a hang, Claude now presses Home, takes 2 screenshots, relaunches once and waits a couple of minutes.

Some things it can’t check at all. Claude’s taps landed on buttons, rows and tab bars, but never flipped a SwiftUI `Toggle` in a `List`, not even one that had worked for weeks, and the accessibility tree was “not available right now” on both devices that day. A toggle that doesn’t flip through the tool can’t be told apart from a broken one, so toggles and VoiceOver get checked by tests and by me.

The rest were rarer:

- I installed Xcode 27.2 and after a CoreSimulatorService restart after that, the stock simulators moved to iOS 27.2 without that runtime installed, so the destination in the project’s instructions stopped resolving.
- An iPhone simulator wouldn’t boot (“liblaunch_sim.dylib could not be opened”), then CoreSimulatorService lost its launchd session: new device, restarted service.
- From inside the sandbox there’s no way to the app’s logs or crash reports (at least because that's how I set it up, denying `~/Library` as a whole), so “did it crash?” sometimes has no answer.

## The missing cancel button

Is all of this worth it, instead of trusting the tests? I think so, because some bugs only show on screen.

Say a dialog offers 3 choices, and the last one, which does nothing, gets the cancel role:

```swift
.confirmationDialog("Delete this link?", isPresented: $isConfirmingDelete) {
   Button("Delete it and stop the test", role: .destructive) { delete(keepingTest: false) }
   Button("Delete it, keep the test") { delete(keepingTest: true) }
   Button("Keep the link", role: .cancel) {} // ❶
}
```

From iOS 26, that’s what shows up on an iPhone:

![A confirmation dialog shown as a popover on an iPhone simulator, with 2 of its 3 buttons and no cancel button][image-1]

A `confirmationDialog` now hides its cancel-role button and cancels on a tap outside instead, so “Keep the link” (❶) just isn’t there. In Digest, that was the dialog for deleting a group of foods while the user was running a test on it, and keeping the group was a choice in its own right, not just a way out, so the flow was broken.

Nothing in a unit test shows that, since the button exists in code either way. It showed up in a render, the real view drawn into an image during a test run, which Claude then looks at. The fix was to drop the role, so “Keep the link” is an ordinary button with an empty action, and a tap outside still cancels the dialog.

[Apple’s docs][11] say the dialog becomes a popover in “regular size classes”, which on iOS mostly means the iPad. But a one-screen test app on an iPhone 17 Pro simulator, on iOS 26.2 and 27.0, does the same: the dialog shows as a popover from its button, without the cancel-role button, and attaching it to the whole screen doesn’t bring it back. An Apple engineer [on the developer forums][12] calls the iOS 26 control changes intended. What I don’t know is whether a tap outside still runs the cancel button’s action; I haven’t checked that one.

Most of these looked like a different problem at first: a sandboxed call like a missing device, a stale capture like a hung app, a filter that matched nothing like a passing run. For each one, there’s now a second thing Claude checks before believing the first: the command line before the device, a `simctl` screenshot before the pane’s, the test’s own line before `TEST SUCCEEDED`. Where there’s no second source (a toggle, VoiceOver, a capture that won’t come back), it’s still me looking at the screen.

Which tests to write in the first place is [the next post][next]; the rest of the series is listed in [Claude Code for iOS development][series].

I’m sure there are a few I haven’t met yet, so if you’ve hit others, I’d really love to hear about them [@roland.leth.ro][13] or [@rolandleth][14].

[prev]: /blog/tech/claude-code-for-ios-development "Claude Code for iOS development"
[next]: /blog/tech/ios-testing-with-claude-code "iOS testing with Claude Code"
[series]: /blog/tech/claude-code-for-ios-development "Claude Code for iOS development"
[1]: https://code.claude.com/docs/en/desktop-ios-simulator "Test iOS apps in the simulator"
[2]: /blog/tech/everything-the-model-forgets-between-sessions "Everything the model forgets between sessions"
[3]: /projects/digest "Digest"
[4]: /projects/reckon "Reckon"
[5]: /projects/continuum "Continuum"
[6]: /blog/tech/claude-code-rules-hooks-and-skills-and-how-i-set-mine-up "Claude Code rules, hooks and skills, and how I set mine up"
[7]: https://code.claude.com/docs/en/sandboxing#run-commands-outside-the-sandbox-with-excludedcommands "Configure the sandboxed Bash tool"
[8]: /blog/tech/the-model-will-tell-you-it-worked-when-it-didnt "The model will tell you it worked when it didn’t"
[9]: /blog/tech/testing-code-when-you-dont-know-the-right-answer "Testing code when you don’t know the right answer"
[10]: /blog/tech/automating-app-store-screenshots-with-claude-code "Automating App Store screenshots with Claude Code"
[11]: https://developer.apple.com/documentation/swiftui/view/confirmationdialog(_:ispresented:titlevisibility:actions:)-46zbb "confirmationDialog(_:isPresented:titleVisibility:actions:)"
[12]: https://developer.apple.com/forums/thread/809150
[13]: https://bsky.app/profile/roland.leth.ro "@roland.leth.ro on Bluesky"
[14]: https://x.com/rolandleth "@rolandleth on X"
[image-1]: https://1b8s9qdvrd8l8jfm.public.blob.vercel-storage.com/posts/tech/claude-code-and-the-ios-simulator-what-breaks/media/claude-code-and-the-ios-simulator-what-breaks/e144d7f816663d15-confirmation-dialog-no-cancel.png "confirmationDialog on an iPhone simulator, iOS 26: a popover from its button, and no cancel button"
