Run Claude Code on a cloud Mac, next to the Simulator
Put the agent on the Mac itself: Claude Code or Codex CLI over SSH, with Xcode and the iOS Simulator local to it and its API key kept as a NoMac secret. Plus when to drive the Mac from your machine instead.
· 6 min read
Need a Mac for this? NoMac gives your agent full macOS with Xcode for $0.80 an hour, billed by the minute. Start now →
An agent can use a cloud Mac in two ways. It can stay where it runs and drive the Mac from there, over MCP or the CLI: each build, test or screenshot is then a call across the network. Or it can run on the Mac itself, where xcodebuild, simctl, the Simulator, logs and crash reports are all local. This guide sets up the second way for Claude Code, and for OpenAI's Codex CLI.
What you end up with: Claude Code running in a terminal on a macOS VM with Xcode, started from your own machine over SSH, with your project on the account's drive and its API key kept as a NoMac secret. The Mac costs $0.80 an hour while it runs, billed by the minute.
What you need
- ·The NoMac CLI 0.12.0 or newer (
npm install -g @nomac/cli, thennomac login), with Node 20 or newer, OpenSSH and rsync. On Windows, use WSL. - ·An Anthropic API key, or a Claude subscription that can make a long-lived token (see step 1). For Codex, an OpenAI API key or a ChatGPT sign-in.
- ·NoMac credit: $10 buys 12.5 hours and never expires.
Step 1: keep the API key as a NoMac secret
Claude Code is not installed on the Mac, and nothing you set up outside ~/drive outlives the session. A NoMac secret does: every Mac you start receives it, as a variable in every command's environment, SSH included. Save the key once from your terminal:
nomac secrets set ANTHROPIC_API_KEY
The value is read from stdin, hidden as you type, and never shown back. You can also enter it at nomac.app/secrets.
With a Claude Pro, Max, Team or Enterprise plan instead of an API key, run claude setup-token on your own computer. Anthropic's authentication docs describe it as a one-year token for places where a browser login is not available. Save it the same way, as CLAUDE_CODE_OAUTH_TOKEN.
A secret saved while a Mac runs reaches it with nomac secrets install. New Macs get it by themselves.
Step 2: start a Mac and name it
cd ~/code/MyApp nomac start --max-duration 28800 --max-cost 7 nomac sync . nomac ssh-config
sync puts the project in ~/drive/src/MyApp, on the account's 50 GB drive, which is kept between sessions. ssh-config adds a host called nomac to your SSH config and prints the project's exact path on the Mac. The limits allow an eight-hour session that spends at most $7; without them it stops after two hours or $5. The Remote-SSH guide explains these steps in more detail.
Step 3: start Claude Code on the Mac
ssh -t nomac 'cd ~/drive/src/MyApp && npx -y @anthropic-ai/claude-code'
-t gives Claude Code a real terminal. npx downloads it on the first run; npm's cache is on the drive, which the next session keeps. With ANTHROPIC_API_KEY set, Claude Code asks once whether to use the key. Its own settings live in the home folder, outside ~/drive, so a new Mac starts it fresh and its first-run questions come again.
Codex CLI instead
Save OPENAI_API_KEY as a secret the same way. OpenAI's authentication docs log the CLI in by piping the key to codex login --with-api-key. On the Mac:
ssh nomac 'printenv OPENAI_API_KEY | npx -y @openai/codex login --with-api-key' ssh -t nomac 'cd ~/drive/src/MyApp && npx -y @openai/codex'
For a ChatGPT sign-in on a remote machine, the same docs point to device code login, codex login --device-auth, which has to be enabled in your ChatGPT security settings. Either login is saved in the home folder, so repeat it on each new Mac.
What the agent can do there
Everything a developer at the Mac can do from a terminal. The account is an administrator, sudo needs no password, and macOS shows no permission prompts to commands. Useful starting points for the agent:
- ·
xcodebuildagainst the project, piped throughxcbeautifyto keep output short. - ·
xcrun simctlto boot a device, install and launch the app, open deep links and save screenshots (xcrun simctl io DEVICE_ID screenshot shot.png), which the agent can then read as images. - ·Crash reports in
~/Library/Logs/DiagnosticReports, and~/NOMAC.md, which describes the Mac. - ·MobileBuildMCP's Simulator tools, added on the Mac with project scope, so the entry is saved in the project's
.mcp.jsonon the drive (run it in the project folder on the Mac).
npx -y @anthropic-ai/claude-code mcp add --scope project xcode -- \ npx -y mobilebuildmcp@latest mcp
To watch, run nomac desktop on your computer: the Mac's screen, with the Simulator once it is open, shows in your browser.
Keep the session alive
Claude Code runs as long as the SSH connection does. If your connection drops, so does the agent. Run it inside tmux to survive that: brew install tmux on the Mac, then start it with ssh -t nomac tmux new -A -s claude and launch Claude Code in that shell. The same command attaches to it again.
NoMac does not see processes left running after SSH closes. While you are connected the Mac runs until its duration limit or spend cap; once no connection or command is left, the idle timeout stops it, ten minutes by default (--idle-timeout, up to 3600 seconds, at start). Reconnect before then, or the Mac and the agent stop.
Getting the work back
The agent edits the Mac's copy in ~/drive/src. sync does not send .git, so either bring files back with nomac pull (for example nomac pull Sources, with --overwrite to replace local files), or clone the repository on the Mac and let the agent commit and push there, with a Git token kept as a NoMac secret.
On the Mac, or driving it from your machine?
Run the agent on the Mac when:
- ·The work is a long loop of builds, tests and Simulator checks, such as UI work where the agent looks at screenshots after each change.
- ·The agent needs many small Mac commands: reading logs, crash reports, simulator state. On the Mac each one runs directly; over MCP each one is a round trip.
- ·You want one place for the agent, its tools and the project for the whole session.
Drive the Mac from where the agent already runs when:
- ·The Mac is one step of a larger task: a build or test run to prove a change, then back to work elsewhere. The Mac then runs only for those minutes.
- ·Your code, Git setup, editor and agent configuration should stay on your machine. See give Claude Code a Mac over MCP.
- ·The agent should not see your secrets. Every Mac you start receives the account's secrets, except those marked on-request, so an agent on the Mac can read them. Keep only what it needs there, and mark the rest on-request.
Stop when you are done
nomac stop
Run it in the project folder on your computer. It deletes the VM and everything outside ~/drive; the project and build caches stay for the next session. All options are in the CLI reference.