# Profile iOS Apps with Instruments on a Rented Mac

Canonical: https://figment.so/blog/mac-instruments-profiling-remote

Boot a simulator, record a Time Profiler trace in Instruments over remote desktop or headlessly with xctrace over SSH, and copy the .trace back. Profilers in a VM see virtualized hardware, so use the Dedicated M4 Pro for performance numbers.

**Instruments runs only on macOS, so record on a rented Mac: open Time Profiler against a booted simulator in a remote desktop session, or record headlessly with `xctrace` over SSH, then copy the `.trace` file back to your laptop.** There is no Windows, Linux or web version of Instruments. One caution applies to every plan: a profiler running inside a virtual machine reports the virtualized hardware, so use it to find hot code paths, and take timing numbers you intend to compare from a whole Mac.

## What does Instruments need from the host?

Instruments ships inside Xcode and uses host-side tracing and hardware counters, so it must run on the same Mac as the simulator or device. Apple describes the toolset in [Improving your app's performance](https://developer.apple.com/documentation/xcode/improving-your-app-s-performance).

For interactive work (scrubbing the timeline, navigating flame graphs, jumping to source) you need a graphical session on the Mac. For scripted recording or CI, the command-line companion `xctrace` records and exports traces without a display. See the [xctrace(1) flag reference](https://keith.github.io/xcode-man-pages/xctrace.1.html).

## How do I connect to the remote Mac?

Use the encrypted remote desktop or browser access for the Instruments window, and SSH for `xctrace`. Instruments' timeline feels sluggish over high-latency links. If scrubbing is painful, record headlessly with `xctrace` in a Terminal on the Mac and copy the `.trace` file down for local analysis.

## How do I record a Time Profiler trace against a simulator?

1. In Xcode, boot the target simulator: **Window → Devices and Simulators → Start Simulator**.
2. Build and run your app once, so dSYM symbols land next to the binary. Instruments uses them to resolve function names.
3. Open Instruments: **Xcode → Open Developer Tool → Instruments** (or `⌘⇧I`).
4. In the template picker, choose **Time Profiler**.
5. In the trace document header, open the target pop-up and pick your booted simulator (for example, *iPhone 16 Pro*).
6. Click **Record** (`⌘R`), exercise the slow path for 15 to 30 seconds, then **Stop**. Very short clips miss infrequent spikes, and long ones produce traces that are slow to scroll remotely.

**CPU Counters** (cycles, cache misses, branch mispredictions) reads the CPU's performance monitoring unit, and inside a VM that is virtualized. Run that template on the Dedicated M4 Pro, which is a whole Mac.

## How do I read the call tree?

After recording, the Call Tree pane ranks functions by time consumed. Three toggles make it navigable:

| Option | Effect |
|---|---|
| **Invert Call Tree** | Shows leaf functions first, where CPU time was actually spent |
| **Hide System Libraries** | Hides Swift runtime, Foundation and UIKit so your code rises to the top |
| **Flatten Recursion** | Collapses recursive cycles into one row |

Turn on Invert Call Tree and Hide System Libraries as the default view. Any function consuming more than 5 to 10% of wall time is a primary optimization candidate. Double-click to jump to the line in Xcode. Enable **Separate by Thread** for GCD or async/await workloads to isolate runaway queues.

## What should I check before a remote session?

- [ ] Remote desktop connected, with the display at least 1440×900 so the Instruments toolbar is not clipped
- [ ] Target simulator booted *before* launching Instruments, otherwise it defaults to the Mac process picker
- [ ] App built at least once, so dSYM files exist on disk
- [ ] Recording kept to 15 to 30 seconds to avoid multi-gigabyte `.trace` files
- [ ] At least 2 GB free disk on the remote Mac (a 30-second Time Profiler trace can reach 500 MB)
- [ ] For arm64-only tools, Metal/GPU or visionOS, you are on an Apple silicon plan, not the Intel VM

## How do I record and export headlessly with xctrace?

The `xctrace` example below is an untested template. Substitute your own app path and simulator name, and run it in the Mac's Terminal (over SSH or in the remote desktop):

```bash
set -euo pipefail

TRACE_DIR="$HOME/traces"
mkdir -p "$TRACE_DIR"
TRACE_FILE="$TRACE_DIR/session-$(date +%Y%m%d-%H%M%S).trace"

xctrace record \
  --template 'Time Profiler' \
  --device 'iPhone 16 Pro' \
  --time-limit 20s \
  --output "$TRACE_FILE" \
  --no-prompt \
  --launch -- /path/to/YourApp.app

xctrace export \
  --input "$TRACE_FILE" \
  --xpath '/trace-toc/run[@number="1"]/data/table[@schema="time-profile"]' \
  --output "$TRACE_DIR/session.xml"
```

`xctrace record` also supports `--attach <pid|name>` for running processes, `--all-processes` for system-wide sampling, and `--window` for ring-buffer mode (see the [xctrace man page](https://keith.github.io/xcode-man-pages/xctrace.1.html)). To open the `.trace` on another Mac, copy it over SSH (`scp` or `rsync`) or through an object store you control, and open it with Instruments. No Xcode project is required.

## Which Figment Mac plan fits profiling?

| Goal | Plan |
|---|---|
| Find hot code paths in an x86_64 simulator build on Xcode 26.3 or earlier | [Intel Mac VM](/mac-hosting#intel-vm), $25 a month or $2 a day. It runs macOS Sequoia and cannot run arm64-only tools or visionOS. |
| Find hot code paths with Xcode 26.4 or later or the arm64 simulator | [Apple Silicon Mac VM](/mac-hosting#apple-silicon-vm), $39 a month or $6 a day. |
| Performance numbers, CPU Counters, Metal/GPU templates | [Dedicated M4 Pro 48 GB](/mac-hosting#dedicated-m4-pro), $349 a month ($299 on a 12-month term). A whole Mac: M4 Pro, 48GB RAM, 512GB SSD. |

Check the macOS version shown before purchase against [Apple's Xcode requirements](https://developer.apple.com/xcode/system-requirements). For a one-off profiling session, the daily rate is cheaper than a month: one day on the Apple Silicon Mac VM is $6, but its vCPUs are shared, so use it for traces rather than tight performance numbers. The Dedicated M4 Pro 48 GB bills by the month only ($349).

For comparison, [CloudMac](https://cloudmac.org/pricing) lists a Mac mini M4 (16 GB / 256 GB) at $99.99 a month, or $999 a year ([cloudmac.org](https://cloudmac.org/)), which is $83.25 a month; its 512 GB and 1 TB rows show "Fully reserved". Twelve months of the Dedicated M4 Pro 48 GB is $3,228 paid up front, and 12 × $99.99 = $1,199.88 for CloudMac monthly. The specs differ (48GB and 512GB against 16 GB and 256 GB), so compare on the memory and disk your traces need. Plans are at [/mac-hosting](/mac-hosting).

**Related guides:** [Manage Provisioning Profiles Without a Local Mac](/blog/mac-provisioning-profiles-headless) · [Swift Package Manager on a Remote Mac](/blog/mac-swift-package-manager-remote) · [GitHub Actions Self-Hosted Runner on Mac](/blog/mac-github-actions-self-hosted-runner)
