# Connect VS Code Tunnel to a Remote Mac for Swift

Canonical: https://figment.so/blog/mac-vscode-tunnel-swift-remote

Run code tunnel --name on the rented Mac, sign in once, then open vscode.dev/tunnel in any browser to edit Swift while compilers and simulators run on the Mac. Use code tunnel service install to survive reboots.

**To edit Swift from any device while the build runs on a rented Mac, run `code tunnel --name figment-mac` on the Mac, sign in once, then open `https://vscode.dev/tunnel/figment-mac` in a browser.** [VS Code Remote Tunnels](https://code.visualstudio.com/docs/remote/tunnels) keep every compiler, language server and simulator on the Mac, so a Chromebook, Windows laptop or iPad becomes a working Swift IDE. The remote machine has to be a Mac for iOS work, because the iOS SDK, Simulator and Apple signing tools are macOS-only.

## Why does Swift and iOS development need a real Mac?

SourceKit-LSP ships with the Swift toolchain on macOS, Linux and Windows, so pure Swift Package Manager projects without Apple-platform targets can be edited anywhere. The moment an iOS, watchOS, tvOS or visionOS target enters the project, that stops working:

- The Xcode SDKs for iOS, watchOS, tvOS and visionOS ship only for macOS.
- The iOS Simulator is a macOS process and does not run on Linux or Windows.
- `xcodebuild`, `codesign` and `notarytool` link against macOS frameworks.
- Per Apple's [porting guide](https://developer.apple.com/documentation/apple-silicon/porting-your-macos-apps-to-apple-silicon), Intel processors use Xcode 26 or earlier, and Xcode 27 requires Apple silicon. visionOS targets need Apple silicon regardless.

The tunnel handles the editor, and the remote Mac does everything only macOS can do.

## How do I install the VS Code CLI and register a named tunnel?

On the remote Mac, open a terminal over SSH or in a remote desktop session. Install VS Code.app and use its bundled `code` binary, or download the standalone CLI from the [VS Code downloads page](https://code.visualstudio.com/Download).

Register a named tunnel. The CLI asks you to authenticate once with a GitHub or Microsoft account, both of which the [tunnels docs](https://code.visualstudio.com/docs/remote/tunnels) support:

```bash
code tunnel --name figment-mac --accept-server-license-terms
```

The CLI prints a device-auth URL. Approve the login, and the terminal confirms the tunnel is active with a URL of the form `https://vscode.dev/tunnel/<machine_name>/<folder_name>`.

## How do I connect from Windows, Linux or a Chromebook?

Open `https://vscode.dev/tunnel/figment-mac` in any modern browser and sign in with the same account. The workspace loads with a file explorer, integrated terminal and extensions, and no local install is needed.

To use a local VS Code window instead:

1. Install the **Remote - Tunnels** extension.
2. Open the Command Palette and run **Remote Tunnels: Connect to Tunnel**.
3. Sign in with the same account and select `figment-mac`.

Both paths give you a terminal running on the Mac, so `xcodebuild`, `swift test` and `xcrun simctl` work as they would locally.

## How do I turn on SourceKit-LSP in the tunnel session?

Install the Swift community extension (`swiftlang.swift-vscode`) inside the connected session. It manages SourceKit-LSP on the remote Mac and provides completions, diagnostics and go-to-definition. Confirm the server is reachable:

```bash
swift --version
xcrun sourcekit-lsp --version
ps aux | grep -v grep | grep sourcekit-lsp
```

If nothing is running after you open a `.swift` file, make sure Xcode (or the standalone Swift toolchain) is installed and selected with `xcode-select -p`. For exact toolchain pairings, check the extension's README and Apple's Xcode release notes rather than guessing a version.

## How do I run xcodebuild from the tunnel terminal?

The integrated terminal runs on the Mac, so build commands need nothing extra. Replace the scheme and destination with values from `xcodebuild -list` in your own project, and do not copy a scheme name you have not verified:

```bash
set -euo pipefail
SCHEME="$(xcodebuild -list -json | python3 -c 'import json,sys;print(json.load(sys.stdin)["project"]["schemes"][0])')"
xcodebuild \
  -scheme "$SCHEME" \
  -destination "platform=iOS Simulator,name=iPhone 16" \
  -configuration Debug \
  build
```

`set -euo pipefail` stops the script when a build fails. Piping into `grep` would mask the exit code and let a broken build look successful. Time the command only after it finishes green.

## How do I keep the tunnel alive across reboots?

Use the built-in service installer. It writes and loads the launchd agent for you, and the command set is stable:

```bash
code tunnel service install --name figment-mac --accept-server-license-terms
code tunnel service log
code tunnel service uninstall
```

Authenticate interactively with `code tunnel` once before installing the service, so the stored credential is in place. The service cannot complete the device-code flow on your behalf. If the Mac reboots or the process crashes, launchd restarts it. Billing does not pause while the tunnel is idle or you are disconnected.

## How does the price compare with other rented Macs?

Figment's Apple Silicon Mac VM is $39 a month, against $99.99 a month for CloudMac's M4 listing. The two are different hardware, so compare specs as well as price. Figures are list prices from each vendor's pricing page.

| Option | Term | Published price | Effective $/mo |
|---|---|---|---|
| Figment Intel Mac VM (4 shared vCPUs, 4GB, 80GB; macOS Sequoia) | monthly | $25 | $25.00 |
| Figment Apple Silicon Mac VM (4 shared vCPUs, 4GB, 65GB) | monthly | $39 | $39.00 |
| Figment Dedicated M4 Pro 48 GB (whole Mac, M4 Pro, 48GB, 512GB) | monthly | $349 | $349.00 |
| Figment Dedicated M4 Pro 48 GB, paid up front | 12 months | $3,228 | $269.00 |
| [CloudMac M4/16 GB/256 GB](https://cloudmac.org/pricing) | monthly | $99.99 | $99.99 |
| [CloudMac M4/16 GB/256 GB annual](https://cloudmac.org/) | annual | $999/yr | $83.25 |
| [MacStadium M4.S 16 GB/256 GB](https://macstadium.com/pricing) | monthly | $149 | $149.00 |

Arithmetic: $999 ÷ 12 = $83.25; $3,228 ÷ 12 = $269. CloudMac's annual bundle is lower than 12 × $99.99 = $1,199.88 and lower than the Dedicated M4 Pro's $3,228 for 12 months paid up front, but availability on its larger disk tiers is marked as fully reserved, so confirm the exact tier when you order. MacStadium publishes a 99.99% uptime commitment and includes support on its listed plans. Figment's VMs share vCPUs, and the Dedicated M4 Pro is a whole Mac, so match the plan to your workload and not only to the monthly figure.

## Which Figment Mac plan fits a tunnel workflow?

For Swift packages or macOS targets on Xcode 26.3 or earlier, the [Intel Mac VM](/mac-hosting#intel-vm) ($25 a month, $2 a day) is the cheapest working tunnel host. It runs macOS Sequoia and cannot run Xcode 26.4 or later, arm64-only tools or visionOS. For newer Xcode, visionOS or Simulator work, use the [Apple Silicon Mac VM](/mac-hosting#apple-silicon-vm) ($39 a month). For heavy builds, choose the [Dedicated M4 Pro 48 GB](/mac-hosting#dedicated-m4-pro) ($349 a month, cancel any time) and test your project in the first days. Check the macOS version shown before purchase against Apple's Xcode table. See all [Mac hosting plans](/mac-hosting).

---

**Related guides:**
- [Run iOS Simulator Over SSH on a Remote Mac](/blog/mac-ios-simulator-ssh-remote)
- [Remote Instruments Profiling on a Mac](/blog/mac-instruments-profiling-remote)
- [Set Up a GitHub Actions Self-Hosted Runner on a Mac](/blog/mac-github-actions-self-hosted-runner)
