Skip to content

Add a Mac in two minutes

iOS simulators only run on macOS, so a farm's iOS capacity grows by adding Macs, not Kubernetes nodes. Adding one takes one command (or one button) on the farm side and one pasted line on the Mac. Then you choose which simulators it runs.

This page is for the people who own test capacity: QA and test engineers. You need an admin key (see Who can manage hosts).

What you need on the Mac

Needed for iOS
macOS A Mac you can leave logged in. Simulators run in a user session, so the agent runs as a login service of that user
Xcode Installed and opened once, with at least one iOS simulator runtime (Xcode > Settings > Components)
Appium appium with the XCUITest driver: npm i -g appium && appium driver install xcuitest
WebDriverAgent A prebuilt WebDriverAgent is recommended, so sessions do not build it (see Device agents on hosts)
Network The Mac can open the farm's URL, and the farm can open port 4800 on the Mac (see How the farm reaches the Mac)

For Android emulators on the same Mac (optional): the Android SDK (platform-tools, emulator, build-tools), at least one AVD, Appium's uiautomator2 driver, and ffmpeg. A Linux machine with KVM can run Android emulators the same way.

Check on the Mac:

xcrun simctl list runtimes                 # at least one iOS runtime
appium --version && appium driver list --installed

You do not install hearth-agent by hand: the join line does it.

Add it

  1. Open the farm's web UI and go to Hosts.
  2. Choose Add a Mac, type a name such as mac-1, and copy the line it shows.
  3. On the Mac, paste the line into Terminal and press Return.
  4. Back in the UI, the host turns online and shows what the Mac can run. Pick the simulators and how many of each, and save.
hearth hosts add mac-1 --wait

It prints the line to paste on the Mac, then waits until the Mac joins and shows what it can run. Then choose its simulators:

hearth hosts plan mac-1 "iPhone 17@iOS 27.2=3" "iPad Air 11-inch (M4)@iOS 27.2=1"

The line looks like this:

curl -fsSL https://hearth.example.com/join.sh | sh -s -- https://hearth.example.com hj_...

It installs hearth-agent into ~/.local/bin if it is missing, trades the one-time code for the host's own token, writes ~/.config/hearth-agent/agent.toml, and starts the agent as a login service (a LaunchAgent, com.testzeus.hearth.agent, on macOS; a systemd user unit on Linux). The agent starts again after a reboot once the user logs in.

The URL in the line is the farm's URL as the CLI knows it. For a farm on another machine, run hearth hosts add with --url https://<farm address> (or HEARTH_URL), not localhost.

Names are 1 to 48 lowercase letters, digits and -, like mac-mini-3.

Choose its simulators

The plan of a host says which devices it runs and how many. The agent creates and removes simulators to match within a minute.

hearth hosts devices mac-1      # iOS runtimes, device types and AVDs on the Mac, and its capacity
hearth hosts plan mac-1 "iPhone 17@iOS 27.2=3"                    # three iPhone 17 on iOS 27.2
hearth hosts plan mac-1 "iPhone 17@27.2=2" "iPad Air 11-inch (M4)@27.2"   # 2 iPhones, 1 iPad
hearth hosts plan mac-1 android:Pixel_8_API_35=2 "iPhone 17@iOS 27.2=2"
hearth hosts plan mac-1 pool:iphone-17-ios-27-2=4                 # a pool the farm already has
hearth hosts plan mac-1 --clear                                   # no devices
You type Means
"<device type>@<runtime>=N" N iOS simulators. Write the device type and runtime as hearth hosts devices lists them; 27.2 is short for iOS 27.2; no =N means one
android:<avd>=N N Android emulators from that AVD
pool:<pool>=N N more devices for a pool that already exists
... as <pool> Name the pool made for these devices, instead of the name the farm picks
  • A plan replaces the whole previous plan.
  • The farm makes one device pool per kind of device, named from it (iphone-17-ios-27-2), and tests reach it like any pool. Macs with the same line share the pool, so two Macs with three iPhone 17 each make one pool of six.
  • Capacity: each simulator or emulator gets 2 cores and 3 GiB of memory, with 4 GiB kept for macOS. A 12-core Mac with 32 GiB has room for 6. A plan that does not fit is refused with plan_does_not_fit. A plan set before the Mac joins is checked when it reports in.
  • The first simulator of each device type takes a few minutes (the agent boots and settles a golden copy once). Later ones are clones and come up fast.
  • Removing devices from a plan never cuts a test short: busy devices finish their session first.

Check: hearth hosts shows the host online with its devices, and hearth status shows the pools with READY devices. Then point Appium at the farm as in Mobile devices.

Day to day

Task Web UI CLI
See every host, capacity use, problems Hosts hearth hosts
One host in detail Click the host hearth hosts show mac-1
Maintenance (updates, reboot) Drain hearth hosts drain mac-1
Back in service Resume hearth hosts resume mac-1
Reinstalled or replaced the Mac Reconnect hearth hosts join-code mac-1 (alias reconnect)
Take it out for good Remove hearth hosts remove mac-1

Drain stops new sessions on the host; running ones finish. Its status goes from draining to drained when nothing runs: then it is safe to update macOS or Xcode, reboot, or switch it off. Resume it afterwards.

Reconnect makes a new join code for the same host name and plan. Paste the new line on the Mac (or its replacement). The agent running now keeps working until the new one joins.

Remove revokes the host's token and forgets it. Sessions still running on it are stopped, so drain first; hearth hosts remove asks before stopping sessions (--yes skips the question). The agent stops its devices after the farm refuses it three times in a row. To clean up the Mac too, run hearth-agent uninstall there (--purge also deletes its settings and token).

Statuses:

Status Meaning
waiting Added; the join line has not been run yet
online Reporting in and taking sessions
offline Its agent stopped reporting (asleep, logged out, switched off)
draining No new sessions; some still running
drained No new sessions and nothing running: safe to switch off

Scale out

Another Mac with the same simulators:

hearth hosts add mac-2 --like mac-1

It copies mac-1's plan, so once mac-2 joins its devices join the same pools. Change it later with hearth hosts plan mac-2 ....

hearth status says when people wait for devices: if a device pool has had requests waiting for a minute with no free device, it suggests adding a Mac. hearth doctor checks hosts too.

Cloud Macs

Hosted and cloud Macs work like any other Mac: the agent only needs a logged-in user session and a network path both ways. Two things to know before renting them by the hour:

  • Some providers bill a minimum allocation. For example, EC2 Mac dedicated hosts have a 24-hour minimum, so adding and removing them for an hour costs a full day.
  • Give the farm a private route to the Mac (same VPC, VPN or tunnel) rather than opening port 4800 to the internet.

How the farm reaches the Mac

Traffic goes both ways:

  • Mac to farm: the agent calls the farm's URL (the one in the join line) every few seconds over HTTPS or HTTP. Outbound only.
  • Farm to Mac: during a session the gateway calls the agent on port 4800 (screens, Appium commands). The agent listens on all interfaces.

The agent advertises the Mac's address on the route to the farm. For a farm on localhost (kind on the same Mac) it advertises http://host.docker.internal:4800. When the farm must use another address (NAT, VPN, a tunnel, a load balancer), add --advertise to the pasted line:

curl -fsSL https://hearth.example.com/join.sh | sh -s -- https://hearth.example.com hj_... \
  --advertise http://10.0.0.12:4800

--port changes the port (default 4800). The farm checks every 30 seconds that it can call the agent back; hearth hosts flags a host it cannot reach as UNREACHABLE with the reason.

Troubleshooting

What you see Fix
Host stays waiting The line was not run, or its code expired (one hour). hearth hosts join-code <host> makes a new one
this join code is unknown, already used or expired on the Mac Each code works once. Make a new one
UNREACHABLE: the farm cannot reach http://...:4800/healthz Allow incoming connections for hearth-agent in the macOS firewall, check the address, or rejoin with --advertise http://<address>:4800
Host offline The Mac sleeps, rebooted to the login window, or the agent stopped. Log in, turn off sleep; read ~/Library/Logs/hearth-agent/agent.log
runtime "iOS 27.2" is not installed on this Mac Install it in Xcode > Settings > Components; the agent reports new runtimes within a minute
this Mac has no simulator type "..." Use a type from hearth hosts devices; newer devices need a newer Xcode
N devices is more than this host can run well Fewer devices, or another Mac (hearth hosts add mac-2 --like mac-1)
Devices stay starting for minutes The first device of a type builds a golden simulator; later ones are fast. Check the agent log
managing hosts needs an admin team's key (403 not_admin) Use an admin key; see below
hearth hosts says the gateway has no host management Upgrade the chart

For Appium errors during sessions, see Troubleshooting.

Who can manage hosts

Only keys of admin teams can list, add, change and remove hosts; other keys get 403 not_admin. The chart's default team is an admin team. Make another:

hearth keys create platform --admin

or set admin: true on a team in the chart values (see Configuration).

helm upgrade --reuse-values

Upgrading an older install with --reuse-values keeps its old teams list, so no team is admin afterwards. Fix it with --set 'teams[0].name=default' --set 'teams[0].admin=true', or with hearth keys create <team> --admin.

Security

  • Join codes work once and for one hour. Anyone with the code can join a machine as that host until it is used, so treat the pasted line like a password: send it to the person at the Mac directly, not in a shared channel or a ticket.
  • Joining trades the code for a per-host token, stored on the Mac in ~/.config/hearth-agent/token, a file only that user can read (mode 0600). It is never shown.
  • The token only lets the agent report its own devices and serve sessions on them. The agent never gets Redis or storage credentials; the gateway keeps those.
  • Removing a host revokes its token at once.
  • A Mac host is single-tenant: all its simulators run under one user account. Do not share one Mac between teams that must not see each other's apps.
  • Only admin teams manage hosts. See Security.

Advanced: hosts in the chart values

Before hosts could be added from the farm, each host was listed under agents: in the chart values, given a token with hearth agent-token <host>, and configured by hand with an agent.toml that lists its devices. That still works, for setups that keep everything in Helm values:

agents:
  - host: mac-1
devicePools:
  - name: iphone17-ios27
    platform: ios
    deviceName: iPhone 17
    osVersion: "27.2"

Such hosts show in hearth hosts with source config and are read-only there: change them in the values and the agent's file. Pools made from the farm and pools from the chart are separate. See Device agents on hosts for the configuration file and service setup.