# Run iOS Simulator Over SSH on a Remote Mac

Canonical: https://figment.so/blog/mac-ios-simulator-ssh-remote

Use xcrun simctl over SSH to boot a device, install a simulator-built .app, launch it, take screenshots and stream logs, with no display attached. Any Figment Mac plan has SSH; the Xcode version decides which one.

**Run `xcrun simctl` over SSH to list and boot a simulator, install a simulator-built `.app`, launch it by bundle ID, take screenshots and stream logs, all without a display.** `simctl` is the command-line interface to CoreSimulator, the service behind Simulator.app, so a booted device runs real UIKit and SwiftUI code against the installed iOS runtime. What you give up headless is interactive touch and the Instruments GUI.

In the commands below, `remote-mac` is a placeholder for the `user@host` you were given. Add a short name for it in your own `~/.ssh/config` if you want one.

## Can the iOS Simulator run without a display?

Yes. Simulator.app is a GUI wrapper around CoreSimulator, and `boot`, `install`, `launch`, `io` and `spawn` all work from a non-graphical SSH session. Two constraints matter before you start:

- **Simulator builds are not device IPAs.** An `.ipa` from TestFlight or a Developer ID build is compiled against the `iphoneos` SDK and signed for a device profile. The simulator runs `.app` bundles built against the `iphonesimulator` SDK, even on an Apple silicon host, so you cannot `simctl install` the `Payload/*.app` from a device IPA. Build a simulator variant (`-sdk iphonesimulator`) and transfer that `.app` directory.
- **The visionOS simulator needs Apple silicon.** [Apple's Xcode system requirements state that developing for visionOS requires a Mac with Apple silicon](https://developer.apple.com/xcode/system-requirements/).

## How do I list and boot a simulator?

List the available devices, capture the UDID of the one you want, and boot it by UDID. A UDID is a 36-character value shaped like `XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX`, and using it avoids ambiguity when several device types share a display name.

```bash
# What's installed?
ssh remote-mac 'xcrun simctl list devices available'

UDID=$(ssh remote-mac "xcrun simctl list devices available -j" \
  | jq -r '[.devices[][] | select(.name=="iPhone 16")][0].udid')
echo "$UDID"

ssh remote-mac "xcrun simctl boot $UDID"
ssh remote-mac "xcrun simctl list devices | grep $UDID"
```

`simctl boot` returns non-zero if the device is already booted. Check state first (`simctl list devices | grep "$UDID"`) rather than blanket-swallowing the error.

## How do I install and launch a simulator app?

Build with the simulator destination, copy the `.app` bundle to the remote Mac, then run `simctl install` and `simctl launch`. Use a per-job `mktemp -d` so parallel runs never collide, and clean up with a `trap` tied to that run's directory, not a blanket `rm -rf /tmp/anything`.

```bash
# On your laptop (or the remote Mac), with the real scheme name from your project:
xcodebuild -scheme "$MY_SCHEME" \
  -configuration Debug \
  -sdk iphonesimulator \
  -destination 'generic/platform=iOS Simulator' \
  -derivedDataPath "$PWD/dd" \
  build

# Copy the simulator .app to a unique scratch directory on the remote Mac:
WORK=$(ssh remote-mac 'mktemp -d /tmp/sim.XXXXXXXX')
trap 'ssh remote-mac "rm -rf $WORK"' EXIT

scp -r "$PWD/dd/Build/Products/Debug-iphonesimulator/MyApp.app" \
  "remote-mac:$WORK/"

ssh remote-mac "xcrun simctl install $UDID $WORK/MyApp.app"
ssh remote-mac "xcrun simctl launch $UDID com.example.MyApp"
```

`simctl launch` prints the PID on success. Pass it to `lldb process attach --pid` if you need to debug.

## How do I stream logs and take screenshots?

`xcrun simctl spawn <udid> log stream` writes the unified log to stdout, and `simctl io <udid> screenshot` writes a PNG of the framebuffer. Filter the log locally with `grep --line-buffered`; without `--line-buffered`, block buffering can stall visible output for seconds.

```bash
ssh remote-mac "xcrun simctl spawn $UDID log stream --level debug" \
  | grep --line-buffered "MyApp"
```

macOS does not ship GNU `timeout`. For a bounded capture, stop the stream with Ctrl-C, install `gtimeout` from Homebrew's `coreutils`, or background the command and `kill` it:

```bash
# Option A: install coreutils once on your laptop, then:
gtimeout 30 ssh remote-mac "xcrun simctl spawn $UDID log stream --level debug" \
  > "sim-$(date +%Y%m%d-%H%M%S).log" || true

# Option B: no extra install, portable:
ssh remote-mac "xcrun simctl spawn $UDID log stream --level debug" > sim.log &
LOG_PID=$!
sleep 30
kill "$LOG_PID" 2>/dev/null || true
```

```bash
ssh remote-mac "xcrun simctl io $UDID screenshot $WORK/shot.png"
scp "remote-mac:$WORK/shot.png" ./shot.png
```

To wait past a launch animation, `launch`, `sleep` a few seconds, then shoot. When a run finishes, shut down only the UDIDs you own, and never `simctl shutdown all` on a shared host, because other developers or CI matrix jobs may be using other devices:

```bash
ssh remote-mac "xcrun simctl shutdown $UDID"
```

## Is there a helper script for this?

Yes. Source this file once per project and export `REMOTE=user@host`. It wires the steps above with the owned-UDID discipline, portable buffering and job-scoped scratch directories. Treat it as a starting point and adapt the names to your project before running it against real builds.

```bash
# simctl-headless.sh — source this file; export REMOTE=user@host in your shell.
: "${REMOTE:?Set REMOTE=user@host}"

sim_udid()     { ssh "$REMOTE" "xcrun simctl list devices available -j" \
                 | jq -r --arg n "$1" '[.devices[][] | select(.name==$n)][0].udid'; }
sim_work()     { ssh "$REMOTE" 'mktemp -d /tmp/sim.XXXXXXXX'; }
sim_boot()     { ssh "$REMOTE" "xcrun simctl boot $1" \
                 || ssh "$REMOTE" "xcrun simctl list devices | grep $1"; }
sim_install()  { ssh "$REMOTE" "xcrun simctl install $1 $2"; }      # $1=UDID $2=app
sim_launch()   { ssh "$REMOTE" "xcrun simctl launch $1 $2"; }       # $1=UDID $2=bundle
sim_shot()     { ssh "$REMOTE" "xcrun simctl io $1 screenshot $2/shot.png"; \
                 scp "$REMOTE:$2/shot.png" ./shot.png; }
sim_shutdown() { ssh "$REMOTE" "xcrun simctl shutdown $1"; }        # $1=UDID only
sim_cleanup()  { ssh "$REMOTE" "rm -rf $1"; }                       # $1=mktemp dir
```

## Should I use headless simctl or an Xcode session over remote desktop?

Use headless `simctl` for CI and automated acceptance tests, and switch to a remote desktop Xcode session only when you need Instruments, interactive gestures or the visionOS simulator.

| Task | Headless `simctl` over SSH | Xcode GUI over remote desktop |
|---|---|---|
| `xcodebuild test` in CI | Best fit | Overkill |
| Screenshot capture | `simctl io screenshot` | Supported |
| Ad-hoc tap/gesture work | Limited (`simctl io help`) | Easier |
| Instruments profiling | Not via `simctl` | Required |
| visionOS simulator | Apple silicon host required | Apple silicon plus GUI |

## Does headless Simulator work need an Apple silicon Mac?

Every Figment Mac plan has SSH, so the Xcode version you need decides the plan. The [Intel Mac VM](/mac-hosting#intel-vm) ($25 a month, $2 a day) runs macOS Sequoia, where Apple lists Xcode 26.0 to 26.3, and that is enough for headless simulator work against the iOS runtimes those versions ship. Choose the [Apple Silicon Mac VM](/mac-hosting#apple-silicon-vm) ($39 a month, $6 a day) for Xcode 26.4 or later, Xcode 27, arm64-only tools or the visionOS simulator, and check the macOS version shown before purchase against Apple's Xcode table. VM vCPUs are shared, so time your own suite.

**Related guides:**
- [Xcode Code Signing on a Remote Mac](/blog/mac-xcode-code-signing-remote)
- [Provisioning Profiles Headlessly on a Mac](/blog/mac-provisioning-profiles-headless)
- [Set Up a GitHub Actions Self-Hosted Runner on a Mac](/blog/mac-github-actions-self-hosted-runner)
