Try it on your Mac
This page measures your iOS app on your Mac, on a simulator or on an iPhone on a cable. Use it to see a session before CI runs one, to measure your branch again, or to measure on a real iPhone.
It starts after step 1 of Getting started: init has set up your app, and you have a CI key. For an Android phone on a cable, see Android.
What you need
- A Mac with Xcode and an iOS simulator.
- Your app with KeepSnappy set up by init, and its
keepsnappy.yml. - Your CI key.
To check that the app is set up, without any CI, run:
npx --no-install keepsnappy doctor --group app --localWith --local, doctor skips the CI checks if your repo has no KeepSnappy workflow yet. If it has one, doctor still checks it, and a problem there shows as WARN.
Each line starts with ok, WARN, MISS or FAIL. Lines with ok passed. Read any WARN line, but it doesn’t stop you. Under a MISS or FAIL line, doctor says what to fix.
Build and install the measuring build
The keepsnappy command does not build or install your app. You build the measuring build, a Release build with KEEPSNAPPY=1, and install it on the simulator yourself.
Boot a simulator and note its UDID:
xcrun simctl list devices bootedFor an Expo app, this builds the measuring build and installs it on that simulator:
KEEPSNAPPY=1 npx expo run:ios --configuration Release --device "<simulator UDID>"If your app’s eas.json profiles are all development-client builds, see Make a Release build.
For a bare React Native app, use your own workspace, scheme and app name:
KEEPSNAPPY=1 xcodebuild -workspace ios/MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination "id=<simulator UDID>" -derivedDataPath buildxcrun simctl install <simulator UDID> build/Build/Products/Release-iphonesimulator/MyApp.appMeasure a session before CI
Put your CI key in the environment, then run your journeys as a session of main, your comparison branch:
export KEEPSNAPPY_KEY='<your CI key>'npx --no-install keepsnappy run --upload --wait --branch main --commit "$(git rev-parse HEAD)" --device "<simulator UDID>" --repeat 3Replace both placeholders first. Keep the real key out of commits and out of terminal output you share.
If you set up a coding agent, your ~/.zshenv may already set KEEPSNAPPY_KEY to a read key, for every shell. With a read key, keepsnappy run --upload fails: the API refuses the key with insufficient_scope. The export above sets the CI key for this shell only, so measure in the same shell (Keys).
Outside GitHub Actions, --branch and --commit have no default, so always pass them, with --wait. Without --branch or --wait, the runs upload but get no session and no result. With only one simulator booted, you can leave out --device.
--repeat 3 runs each journey 3 times, to keep this first session short. CI runs each journey 5 times. One failed run leaves this session short of the 3 valid runs a comparison needs.
With one journey, the log shows 3/3 runs valid and then uploaded 3 runs to …. With more journeys, the counts cover all of them, such as 6/6 runs valid for two. With --wait, the command then waits for the result and prints it.
With --branch main, this session counts as one of main’s sessions on that simulator’s phone model. It becomes part of main’s baseline: until CI has run main 3 times on the same model, pull requests are compared with it. So run it on a commit that is on main.
If the session fails
Each line starts with what the log says:
Session failed: no run sent any data. Check that the build carries the SDK and that the app reaches the API.The installed build was made withoutKEEPSNAPPY=1, or it is not the build on the simulator you named.- Runs the log lists as
test-failed: the test itself failed. Readtest.login its run folder underkeepsnappy-out. - Runs the log lists as
no-windows: the SDK measured nothing during the run, no screen, tap or scroll. Check that the measuring build is active on the device you selected and that the journey reaches a screen or taps while the run is capturing data.
Troubleshooting has more of them, each with its fix.
Measure your branch again
To measure the commit you have checked out as a new session of your branch, build and install the measuring build again, then run:
npx --no-install keepsnappy run --upload --wait --branch my-feature --commit "$(git rev-parse HEAD)" --device "<simulator UDID>"Use your branch’s name in place of my-feature. The session is compared with main on the same phone model, so boot the simulator model your CI uses. On any other model, main has no sessions there, and the result is No main to compare.
Without --upload, the runs are measured on your Mac and get no result.
A build that waits for activation
Some builds measure nothing until KeepSnappy switches measuring on before a run (activation). If your build uses the SDK option waitForActivation, set app.wait_for_activation to true in keepsnappy.yml (settings).
Before every run, the keepsnappy command stops the app and writes the activation into the app’s data folder on the simulator. After the last run, it switches the activation off. Your test command must start the app fresh, without clearing its data or reinstalling it.
An iPhone on a cable
Plug the iPhone into your Mac and unlock it. Then find its id:
xcrun devicectl list devicesYour CI reads keepsnappy.yml, so keep the phone’s settings in a copy of it, such as keepsnappy-iphone.yml. In the copy, set platform to ios-device, and device to the iPhone’s id.
Build the measuring build for the iPhone and install it. Xcode must be able to sign it for that phone. For an Expo app:
KEEPSNAPPY=1 npx expo run:ios --configuration Release --device "<the iPhone's name>"Then run your journeys with the copy:
npx --no-install keepsnappy run --config keepsnappy-iphone.yml --upload --wait --branch main --commit "$(git rev-parse HEAD)" --device-model <model code> --device-os <iOS version>The keepsnappy command reads a simulator’s phone model for you, but not an iPhone’s. Pass its model code, such as iPhone16,1, and its iOS version. The model code is the phone’s productType in the file that xcrun devicectl list devices --json-output devices.json writes. The session is then compared only with sessions on the same phone model, so main needs 3 sessions on that model too.
On the iPhone:
- The
keepsnappycommand copies the measurements off the phone withdevicectland uploads them with your CI key. The build needs no SDK key. - Your test command must be able to drive the iPhone. The
keepsnappycommand adds--devicewith the phone’s id to a Maestro command. - The
keepsnappycommand can’t activate a build with the SDK optionwaitForActivationon an iPhone, so it refusesapp.wait_for_activationthere. Use a build without that option. - If the iPhone is locked or unplugged, the command stops with
device <id> is not connected: plug it in and unlock it.