iOS Simulator harness for iPhone layout checks #451

Closed
opened 2026-10-15 17:48:46 +00:00 by kayg · 3 comments
Owner

A reusable iOS Simulator harness, so iPhone layout (safe areas, Safari's floating toolbar, the Home Screen app, the keyboard) can be checked without kayg's phone.

It runs from calternal-dev and drives the iOS Simulator on kayg's Mac over NetBird SSH. Everything on the Mac stays under ~/calternal-sim. No system-wide installs.

One command should:

  1. Start a test server on calternal-dev from a git ref (default origin/dev), built in /home/kayg/Developer/calternal-wt-sim through the build slots, with a test user and seeded notes: a Journal with many days, notes with links, a photo backdrop.
  2. Sign the simulator into it.
  3. Open a URL in Safari, and add the site to the Home Screen and open it as the standalone app.
  4. Rotate, show and hide the keyboard, switch light and dark.
  5. Take screenshots, fetch them, and record measurements from inside the page: innerHeight, outerHeight, screen., visualViewport., env(safe-area-inset-*), display-mode: standalone, and the boxes of the list scroller, the backdrop and the + button.

First use: #445 (the band at the bottom of the Journal list in the Home Screen app), before (origin/dev) and after (PR #447).

Caveat: the simulator runs iOS 27.0. kayg's phone may run iOS 26.x, and the simulator is not a device.

A reusable iOS Simulator harness, so iPhone layout (safe areas, Safari's floating toolbar, the Home Screen app, the keyboard) can be checked without kayg's phone. It runs from calternal-dev and drives the iOS Simulator on kayg's Mac over NetBird SSH. Everything on the Mac stays under `~/calternal-sim`. No system-wide installs. One command should: 1. Start a test server on calternal-dev from a git ref (default `origin/dev`), built in `/home/kayg/Developer/calternal-wt-sim` through the build slots, with a test user and seeded notes: a Journal with many days, notes with links, a photo backdrop. 2. Sign the simulator into it. 3. Open a URL in Safari, and add the site to the Home Screen and open it as the standalone app. 4. Rotate, show and hide the keyboard, switch light and dark. 5. Take screenshots, fetch them, and record measurements from inside the page: innerHeight, outerHeight, screen.*, visualViewport.*, env(safe-area-inset-*), display-mode: standalone, and the boxes of the list scroller, the backdrop and the + button. First use: #445 (the band at the bottom of the Journal list in the Home Screen app), before (origin/dev) and after (PR #447). Caveat: the simulator runs iOS 27.0. kayg's phone may run iOS 26.x, and the simulator is not a device.
Author
Owner

Progress: the harness works end to end, over SSH, with nothing installed on the Mac.

  • Server: sim/server.sh REF PORT builds REF in its own worktree (through the build slots), runs calternal serve on calternal-dev's loopback with the e2e --dev-user (option (a): the existing test sign-in, no new code), seeds a photo backdrop, 75 Journal days and 24 linked notes, and tunnels it to the Mac's loopback with netbird ssh -R. The simulator opens http://localhost:PORT: a secure context (service worker, Home Screen app), and --dev-user stays loopback-only at both ends.
  • UI automation: a tiny XCUITest runner (~/calternal-sim/runner, built with xcodebuild build-for-testing, run step by step with test-without-building). It adds the site to the Home Screen through Safari's Page Menu ▸ Share ▸ Add to Home Screen, opens the icon, rotates, taps. It works from the NetBird SSH (Background) session.
  • In-page numbers: a ~150-line Python client for the simulator's Web Inspector socket (com.apple.webinspectord_sim.socket, binary-plist RPC + Runtime.evaluate through the Target domain). It reaches both Safari tabs and the Home Screen app (which runs in com.apple.SafariViewService). No ios_webkit_debug_proxy needed.

First numbers, origin/dev, iPhone 18 Pro simulator, iOS 27.0, Home Screen app, portrait: innerHeight 874 = screen.height, the fixed box 874, 100svh 812, 100lvh/100dvh 874, safe areas 62 / 34. kayg's phone also runs iOS 27.

Open: the software keyboard. The headless simulator treats a hardware keyboard as connected, so a tap in a note focuses it (caret, edit bar) but the keyboard stays below the screen.

Progress: the harness works end to end, over SSH, with nothing installed on the Mac. - **Server**: `sim/server.sh REF PORT` builds REF in its own worktree (through the build slots), runs `calternal serve` on calternal-dev's loopback with the e2e `--dev-user` (option (a): the existing test sign-in, no new code), seeds a photo backdrop, 75 Journal days and 24 linked notes, and tunnels it to the Mac's loopback with `netbird ssh -R`. The simulator opens `http://localhost:PORT`: a secure context (service worker, Home Screen app), and `--dev-user` stays loopback-only at both ends. - **UI automation**: a tiny XCUITest runner (`~/calternal-sim/runner`, built with `xcodebuild build-for-testing`, run step by step with `test-without-building`). It adds the site to the Home Screen through Safari's Page Menu ▸ Share ▸ Add to Home Screen, opens the icon, rotates, taps. It works from the NetBird SSH (Background) session. - **In-page numbers**: a ~150-line Python client for the simulator's Web Inspector socket (`com.apple.webinspectord_sim.socket`, binary-plist RPC + `Runtime.evaluate` through the Target domain). It reaches both Safari tabs and the Home Screen app (which runs in `com.apple.SafariViewService`). No `ios_webkit_debug_proxy` needed. First numbers, origin/dev, iPhone 18 Pro simulator, iOS 27.0, Home Screen app, portrait: `innerHeight` 874 = `screen.height`, the fixed box 874, `100svh` 812, `100lvh`/`100dvh` 874, safe areas 62 / 34. kayg's phone also runs iOS 27. Open: the software keyboard. The headless simulator treats a hardware keyboard as connected, so a tap in a note focuses it (caret, edit bar) but the keyboard stays below the screen.
Author
Owner

The harness is done and has had its first real use (#445 → PR #455). Everything runs from calternal-dev; on the Mac it uses only xcrun simctl, xcodebuild (the XCUITest runner) and the system python3/swift, all under ~/calternal-sim.

Commands (in the coordinator's scratchpad sim/, README.md there):

  • server.sh REF PORT: builds REF in calternal-wt-sim[-PORT] through the build slots, serves it with --dev-user on loopback, seeds it, and tunnels it to the Mac's localhost:PORT (netbird ssh -R).
  • capture.sh PORT LABEL [--modes webapp,safari] [--themes light,dark] [--screens …] [--orient landscape]: every screen in the Home Screen app (icon Cal PORT, added through Share ▸ Add to Home Screen if missing) and in a Safari tab, light and dark. It saves screenshots plus in-page numbers (probe.js). About 8 s a shot.
  • bands.py: finds seams at the top and bottom edges, numerically. contact.py / sheets.sh build contact sheets (pure Python).
  • flick.sh (on the Mac): a 60 fps simctl io recordVideo of a route change, with the per-frame colour of the status bar and the bottom read by a small Swift/AVFoundation script, to catch bar-colour flicker.
  • sim …: single steps (open, addhome, openhome, rotate, appearance, tap, eval, measure, shot).

Known limit: the software keyboard. The headless simulator acts as if a hardware keyboard is connected, so a tap focuses the text (caret, edit bar) but the keyboard stays below the screen. Turning that off needs the macOS Simulator app's own setting or its window, which is outside what I may touch on the Mac. Keyboard checks stay on the phone's checklist for now.

The harness is done and has had its first real use (#445 → PR #455). Everything runs from calternal-dev; on the Mac it uses only `xcrun simctl`, `xcodebuild` (the XCUITest runner) and the system `python3`/`swift`, all under `~/calternal-sim`. Commands (in the coordinator's scratchpad `sim/`, README.md there): - `server.sh REF PORT`: builds REF in `calternal-wt-sim[-PORT]` through the build slots, serves it with `--dev-user` on loopback, seeds it, and tunnels it to the Mac's `localhost:PORT` (`netbird ssh -R`). - `capture.sh PORT LABEL [--modes webapp,safari] [--themes light,dark] [--screens …] [--orient landscape]`: every screen in the Home Screen app (icon `Cal PORT`, added through Share ▸ Add to Home Screen if missing) and in a Safari tab, light and dark. It saves screenshots plus in-page numbers (`probe.js`). About 8 s a shot. - `bands.py`: finds seams at the top and bottom edges, numerically. `contact.py` / `sheets.sh` build contact sheets (pure Python). - `flick.sh` (on the Mac): a 60 fps `simctl io recordVideo` of a route change, with the per-frame colour of the status bar and the bottom read by a small Swift/AVFoundation script, to catch bar-colour flicker. - `sim …`: single steps (open, addhome, openhome, rotate, appearance, tap, eval, measure, shot). Known limit: the software keyboard. The headless simulator acts as if a hardware keyboard is connected, so a tap focuses the text (caret, edit bar) but the keyboard stays below the screen. Turning that off needs the macOS Simulator app's own setting or its window, which is outside what I may touch on the Mac. Keyboard checks stay on the phone's checklist for now.
Author
Owner

Closing during the 26 Oct handover cleanup: The simulator harness is done and in use. It now lives on the Mac Studio (~/Developer/calternal-sim).

Closing during the 26 Oct handover cleanup: The simulator harness is done and in use. It now lives on the Mac Studio (`~/Developer/calternal-sim`).
kayg closed this issue 2026-10-26 08:46:31 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal#451
No description provided.