MONKEYTESTERDOCS
Docs / Machines / Mac

Set up the Mac

The MonkeyTester-Mac app is archived and no longer developed; its repository is kept read-only for reference. Do not install it. This page sets up the Mac's services directly — the Mobile Controller, MonkeyTester-Plugin-AI and the build-local plugin — and remains current.

The Mac owns the phones (MonkeyTester-Plugin-Mobile-Controller), runs the vision model (MonkeyTester-Plugin-AI) and runs the build plugin (build-local) that builds the apps for Build & Test. The lab uses an Apple silicon Mac at 192.168.125.71 on macOS 27.2 with Xcode 27.2.

Requirements

  • A Mac with Apple silicon. The AI service needs Metal for Ollama; Intel Macs can run the controller but not the model.
  • 16 GB of memory or more for the default model (qwen2.5vl:7b-q4_K_M). With 8 GB use qwen2.5vl:3b-q4_K_M, or a remote model server.
  • About 8 GB free disk for Ollama and the model, plus room for Xcode and the Android SDK.
  • An Apple Developer team (for signing WebDriverAgent and the app under test).
  • A user that stays logged in to the GUI. The services are LaunchAgents: they need the login keychain (signing) and the USB devices of that session. Turn on automatic login and stop the Mac sleeping.

Install the toolchain

Xcode

Install Xcode from the App Store, open it once to finish installing components, and sign in with your Apple ID under Settings → Accounts so it can create the development certificate. Then point the command line at it:

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
xcodebuild -version
security find-identity -v -p codesigning     # an "Apple Development: …" identity must be listed

If xcode-select -p still shows the Command Line Tools, export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer in every service that builds or signs (the lab sets it in the controller's LaunchAgent and the build plugin's LaunchAgent).

Homebrew, Node, ffmpeg, Appium

# Homebrew from https://brew.sh, then:
brew install node ffmpeg
npm install -g appium
appium driver install xcuitest
appium --version && appium driver list --installed

The controller starts Appium itself on :4723 when nothing is listening, with --allow-insecure xcuitest:xctest_screen_record (needed for iOS screen recording). If you run your own Appium instead (APPIUM_URL), start it with that flag.

Android SDK and JDK

The controller uses adb from $ANDROID_HOME/platform-tools, default ~/Library/Android/sdk. Install the SDK there with Android Studio, or with the command-line tools. Gradle builds also need a JDK; the lab uses Temurin 21 as the system JDK.

brew install --cask temurin@21                # or any JDK 21
# with Android Studio's SDK Manager, or cmdline-tools:
sdkmanager "platform-tools" "platforms;android-35" "build-tools;35.0.0"
~/Library/Android/sdk/platform-tools/adb version

Pick the platform and build-tools versions your app's Gradle build asks for.

MonkeyTester-Plugin-Mobile-Controller

The controller is one Python file using only the standard library. It exposes every phone over HTTP on :8090 (API.md in its repo is the contract).

mkdir -p ~/Workspace && cd ~/Workspace
git clone https://github.com/yurivibes/MonkeyTester-Plugin-Mobile-Controller.git
cd MonkeyTester-Plugin-Mobile-Controller

Try it in the foreground

APPIUM_ORG_ID=<TEAM_ID> \
APPIUM_SIGNING_ID="Apple Development" \
APPIUM_WDA_BUNDLE_ID=com.blackjackfruit.WebDriverAgentRunner \
CONTROLLER_TOKEN=<CONTROLLER_TOKEN> \
python3 device_controller.py
# -> 0.0.0.0:8090

The controller listens on the LAN, so after the security update it refuses to start without CONTROLLER_TOKEN (generate one with openssl rand -hex 32). Only with CONTROLLER_BIND=127.0.0.1 is the token optional.

Your team ID is listed under Membership at developer.apple.com/account. APPIUM_WDA_BUNDLE_ID must be a bundle id your team can sign; change the prefix to your own.

curl -s localhost:8090/health     # {"ok": true, "service": "monkeytester-mobile-controller", "api_version": 2, "appium": true, "adb": true}
curl -s -H "X-Controller-Token: $CONTROLLER_TOKEN" localhost:8090/devices    # connected phones with their platform

The first iOS session builds WebDriverAgent onto the iPhone, which can take several minutes. macOS may ask for keychain access to sign it: choose Always Allow, otherwise the LaunchAgent can't sign later.

Start it at login (LaunchAgent)

Copy packaging/launchd/com.blackjackfruit.monkeytester-mobile-controller.plist, fill in the placeholders (REPLACE_USER, the checkout path, REPLACE_TEAM_ID), and install it. The lab's copy also sets these keys, which keep it in the GUI session where the keychain and USB devices are:

<key>WorkingDirectory</key>      <string>/Users/<you>/Workspace/MonkeyTester-Plugin-Mobile-Controller</string>
<key>LimitLoadToSessionType</key> <string>Aqua</string>
<key>ProcessType</key>           <string>Interactive</string>
<!-- inside EnvironmentVariables: -->
<key>DEVELOPER_DIR</key>         <string>/Applications/Xcode.app/Contents/Developer</string>
<key>CONTROLLER_TOKEN</key>      <string><CONTROLLER_TOKEN></string>
cp packaging/launchd/com.blackjackfruit.monkeytester-mobile-controller.plist ~/Library/LaunchAgents/
# edit the copy in ~/Library/LaunchAgents/, then:
launchctl load -w ~/Library/LaunchAgents/com.blackjackfruit.monkeytester-mobile-controller.plist
tail -f /tmp/monkeytester-mobile-controller.log

To restart after an update: git pull, then launchctl unload and load the plist (or launchctl kickstart -k gui/$(id -u)/com.blackjackfruit.monkeytester-mobile-controller).

Controller settings

VariableDefaultPurpose
CONTROLLER_PORT8090HTTP port
CONTROLLER_BIND0.0.0.0Bind address
CONTROLLER_TOKENnoneRequired unless CONTROLLER_BIND is loopback (the controller refuses to start without it). Clients send it as X-Controller-Token on all routes but /health; enter the same value in the viewer's Settings (Security → Setting up tokens)
APPIUM_URLhttp://127.0.0.1:4723Appium to use; started automatically if nothing listens
APPIUM_ORG_ID—Xcode team id for WDA signing
APPIUM_SIGNING_IDApple DevelopmentSigning identity
APPIUM_WDA_BUNDLE_ID—Bundle id for WebDriverAgent
APPIUM_CAPS_JSON—Extra Appium capabilities (JSON)
ANDROID_HOME / ADB_BIN~/Library/Android/sdkWhere adb is
JAVA_HOMEautoJDK for Appium's UiAutomator2 driver
ADB_CONNECT—Comma list of wireless IP:PORT to keep connected (retried every 30 s)

MonkeyTester-Plugin-AI (vision model)

Runs Qwen2.5-VL through its own private copy of Ollama (pinned, in .runtime/ inside the checkout; it never touches another Ollama). It can also forward to a remote server or GitHub Copilot, see Vision model providers.

cd ~ && git clone https://github.com/yurivibes/MonkeyTester-Plugin-AI.git
cd MonkeyTester-Plugin-AI
python3 --version                       # 3.9+; from the Xcode command line tools
python3 -m unittest discover tests      # fake Ollama/GitHub/remote, downloads nothing
bin/monkeytester-ai setup               # downloads Ollama + the model (~6 GB), verifies both; safe to rerun

Do not install Ollama with Homebrew for this; setup brings its own.

Check that it can see

bin/monkeytester-ai serve               # terminal 1
bin/monkeytester-ai ask tests/fixtures/target.png \
  'Find the red rectangle. Return ONLY JSON: {"found": true/false, "coordinates": [x, y], "bbox": [x1, y1, x2, y2]}'

coordinates should be close to [585, 1280].

Serve on the LAN

The viewer runs on another machine, so the service must listen on the network, which requires a token (the pairing token):

export MTAI_TOKEN=$(openssl rand -hex 32)
echo "$MTAI_TOKEN"                      # keep it: you paste it into the viewer
bin/monkeytester-ai service install --lan   # starts now and at every login, with the current env
bin/monkeytester-ai status

service install captures the environment of your shell at install time, so export every MTAI_* setting first and reinstall to change them. Allow incoming connections for Python in the macOS firewall. Traffic is plain HTTP: trusted networks only.

Then register it in the viewer: Linux host → Connect the viewer, step 2. Tests call it by its plugin name, AI by default (AI: VERIFY …, AI: CLICK …); renaming it in its Configure panel changes that name, the CLI stays bin/monkeytester-ai.

AI settings

VariableDefaultPurpose
MTAI_MODELqwen2.5vl:7b-q4_K_MStarting local model; switchable later from the viewer. Use qwen2.5vl:3b-q4_K_M under 16 GB and rerun setup
MTAI_TOKENnonePairing token; required with --lan
MTAI_PORT8091Service port
MTAI_OLLAMA_PORT11435Private Ollama port
MTAI_MAX_PIXELS1000000Largest image the model sees; stay under ~3M
MTAI_RUNTIME_DIR.runtimeWhere Ollama, the model, settings and secrets live

Commands: setup, serve [--lan], status [--json], ask, service install [--lan], service uninstall, clean [--yes]. Logs: .runtime/logs/ollama.log and service.log.

Build plugin (build-local)

Build & Test builds the APK and the signed IPA on this Mac, because iOS signing lives here and so does the Android SDK. The build-local build plugin fetches the branch from the code host you configure (Gitea or GitHub), runs the app repo's .monkeytester/build-<platform>.sh scripts here and uploads the apps back to the viewer (see Build & Test).

What the Mac offers: Xcode (xcodebuild -version — the plugin detects iOS), the Android SDK (detected via ANDROID_HOME / ANDROID_SDK_ROOT / ~/Library/Android/sdk / ~/Android/Sdk) and a JDK — so it builds Android and iOS. A Linux host with the Android SDK and a JDK builds Android only.

cd ~/Workspace && git clone https://github.com/yurivibes/MonkeyTester-Plugin-Build-Local.git
cd MonkeyTester-Plugin-Build-Local
nix run .                              # plugin on :8094 (or python3 build_plugin.py)
nix run .#tests                        # unit tests against a fake Gitea/GitHub (or: python3 -m unittest discover -s tests -v)

Keep it running with packaging/launchd/com.blackjackfruit.monkeytester-build-local.plist (a LaunchAgent; replace CHECKOUT_DIR and PYTHON, add PLUGIN_TOKEN to its EnvironmentVariables, then launchctl load -w ~/Library/LaunchAgents/com.blackjackfruit.monkeytester-build-local.plist). It uses the Aqua session type, so the code-signing identity for the signed .ipa must be in the login keychain of the user the agent runs as (choose Always Allow if macOS asks for keychain access); the provisioning profile must cover each test iPhone's UDID.

VariableDefaultPurpose
PLUGIN_PORT8094Plugin port (PLUGIN_HOST default 0.0.0.0)
PLUGIN_TOKENnonePairing token; required unless PLUGIN_HOST is loopback (the plugin refuses to start without it). Every request except GET /health must send it as X-Plugin-Token or Authorization: Bearer
BUILD_PLUGIN_STATE_DIR~/.config/monkeytester-build-local/config.json (code host + token + viewer URL, mode 0600), builds.json, checkouts/, out/ (the newest 50 builds keep their files)
BUILD_LOCAL_PLATFORMSauto-detecte.g. android to force Android only
BUILD_LOCAL_TIMEOUT_ANDROID / BUILD_LOCAL_TIMEOUT_IOS3600Seconds a platform's build script may run

Then register it in the viewer: Linux host → Connect the viewer, Build & Test step (Settings → Plugins → Build Plugin). The plugin runs the scripts of the branch it builds — run it as a dedicated, never-root user, and only add trusted repos as projects.

Mac checklist

  • curl -s http://192.168.125.71:8090/health shows "appium": true, "adb": true
  • curl -s http://192.168.125.71:8090/devices lists the iPhone and the Android phone
  • bin/monkeytester-ai status shows the model installed and the service running
  • The viewer's /api/status shows controller.ok and vision.ok
  • curl -s http://192.168.125.71:8094/health answers the build plugin contract, with its code host and the platforms it can build