# Debug iOS Apps Remotely with LLDB on a Rented Mac

Canonical: https://figment.so/blog/mac-lldb-remote-debug-xcode

Launch the app with xcrun simctl launch --wait-for-debugger, then attach with lldb -p or lldb -n --waitfor. It runs entirely in an SSH terminal, so any Figment Mac plan works; the Xcode version you need picks the plan.

**Launch the app paused with `xcrun simctl launch --wait-for-debugger`, then attach with `lldb -p <pid>` or `lldb -n MyApp --waitfor`.** [LLDB](https://lldb.llvm.org/use/tutorial.html) is a full command-line debugger, so it does not need the Xcode GUI to attach, set breakpoints or evaluate Swift expressions. Run every command below on the remote Mac itself, for example over `ssh -t`.

## How does LLDB attach to an iOS Simulator process?

The Simulator runs each app as a regular macOS process owned by your user account, so LLDB attaches by PID or by process name. No daemon, port forwarding or extra entitlement is required.

- **Wait-for-name** (`lldb -n MyApp --waitfor`): LLDB blocks until a process with that name launches, then stops it at the first instruction it can.
- **Attach by PID** (`lldb -p 12345`): useful when the app is already running. Find the PID with `pgrep -f MyApp.app` or from `xcrun simctl launch` output.

Combined with `xcrun simctl launch --wait-for-debugger`, this gives a deterministic "launch paused, attach, continue" loop.

## How do I build, install and launch the app paused?

Build a Debug configuration, boot the simulator, install the `.app`, and launch with `--wait-for-debugger`. Replace `MyApp`, `MyAppScheme` and `com.example.MyApp` with your project's values.

```bash
cd ~/MyApp
set -euo pipefail

xcodebuild \
  -scheme MyAppScheme \
  -destination 'platform=iOS Simulator,name=iPhone 16' \
  -configuration Debug \
  -derivedDataPath /tmp/MyApp-derived \
  build

APP_PATH=$(find /tmp/MyApp-derived/Build/Products/Debug-iphonesimulator \
  -maxdepth 2 -name 'MyApp.app' -not -path '*Tests*' | head -1)
echo "APP_PATH=$APP_PATH"
```

`set -euo pipefail` stops the script on the first failing command, so a failed build never falls through to install or launch.

```bash
xcrun simctl boot 'iPhone 16' 2>/dev/null || true
xcrun simctl install booted "$APP_PATH"
```

```bash
xcrun simctl launch --wait-for-debugger --console-pty booted com.example.MyApp
# Output example:
# com.example.MyApp: 48123
```

The PID is the number after the colon. Open a second shell on the same Mac and attach:

```bash
lldb -p 48123
```

To attach by name so you can relaunch without copying a PID:

```bash
# Shell A on the Mac
lldb -n MyApp --waitfor

# Shell B on the Mac
xcrun simctl launch --wait-for-debugger booted com.example.MyApp
```

Once attached, LLDB sits at the first user frame. `continue` resumes execution and your breakpoints take over.

## How do I set breakpoints and step?

Use `breakpoint set` with a file and line, a function name or an Objective-C selector ([LLDB tutorial](https://lldb.llvm.org/use/tutorial.html)):

```
(lldb) breakpoint set --file ContentView.swift --line 42
(lldb) breakpoint set --name viewDidLoad
(lldb) breakpoint set --selector dealloc
(lldb) breakpoint list
(lldb) breakpoint disable 1
(lldb) continue
```

`thread step-over`, `thread step-in` and `thread step-out` move through a stopped frame. The aliases later in this guide shorten them to `n`, `s` and `f`.

## How do I inspect Swift structs?

At a stop, `frame variable` lists locals and arguments in the current frame, `po` runs the debug description, and `expression` evaluates Swift in the frame.

```
(lldb) frame variable          # all locals, current values
(lldb) frame variable self     # self and its stored properties
(lldb) frame variable -T       # add type annotations

(lldb) po self.viewModel
(lldb) po self.viewModel.items.count

(lldb) expression self.viewModel.items.count
(lldb) expression var $copy = self.viewModel; $copy.reset(); po $copy
```

If Swift type checking fails on complex generics, fall back to `p` for a simpler value print or `frame variable` for a non-evaluated dump.

## What should go in .lldbinit?

LLDB reads `~/.lldbinit` on the Mac at startup. These aliases map to the commands you type most in a terminal session:

```
# ~/.lldbinit on the remote Mac

command alias vt frame variable -T
command alias vs frame variable self
command alias dump expression -O --
command alias wp  watchpoint set variable
command alias bts thread backtrace --count 20
command alias n   thread step-over
command alias s   thread step-in
command alias f   thread step-out
```

Confirm the file loaded after restarting LLDB:

```
(lldb) help vt
# Current executable set to 'Alias for: frame variable -T'
```

A watchpoint on a property is a good pattern for "who is writing this value":

```
(lldb) breakpoint set --name viewDidLoad
(lldb) continue
# ... hits viewDidLoad ...
(lldb) wp self.count
# Watchpoint created; LLDB stops on the next write to self.count
(lldb) continue
```

## Does LLDB over SSH work on every plan?

Any plan fits, because the whole workflow runs in an SSH terminal. 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 covers LLDB against the iOS Simulator. Pick the [Apple Silicon Mac VM](/mac-hosting#apple-silicon-vm) ($39 a month, $6 a day) for Xcode 26.4 or later, Xcode 27 or visionOS targets. Check the macOS version shown before purchase against Apple's Xcode table.

**Related guides:**
- [Remote Instruments Profiling on a Mac](/blog/mac-instruments-profiling-remote)
- [Xcode Code Signing on a Remote Mac](/blog/mac-xcode-code-signing-remote)
- [Set Up a GitHub Actions Self-Hosted Runner on a Mac](/blog/mac-github-actions-self-hosted-runner)
