Files
wikideck/docs/night/IOS.md
T

110 lines
7.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# iOS app and macOS VM (Night 1, mobile-ios, issue #9)
## Status at a glance
- **macOS VM:** QEMU/KVM on inspiron-3670, OSX-KVM style. Sequoia (15) recovery booted, disk erased (APFS volume `machd`),
licence accepted, and **"Reinstall macOS Sequoia" was downloading the full OS from Apple** over inspiron's Wi-Fi
(installer estimate ~2 h 50 min from 23:33). Per the coordinator, the VM is **shut down cleanly before 01:30**
with the disk kept. See "Progress at shutdown" below for exactly where it got to.
- **No Apple ID** was created or used. Nothing signed in to Apple.
- **iOS Capacitor project:** `ios/` (Capacitor **7.6.x**, Swift Package Manager, no CocoaPods), app id
`dev.eom.wikideck`, URL scheme `dev.eom.wikideck` registered for the SSO redirect.
- **Build script:** `scripts/ios/build-sim.sh` (run inside the VM once Xcode is installed). Not yet run: needs Xcode.
## Where things are (inspiron-3670, outside git)
| Path | What |
|---|---|
| `~/worker/jobs/macos/boot-macos.sh` | Starts the VM: 8 GB RAM, 4 vCPU, q35, OpenCore, VNC 127.0.0.1:5911, SSH fwd 127.0.0.1:10022 |
| `~/worker/jobs/macos/mac_hdd_ng.qcow2` | 80 GB macOS system disk (keep this) |
| `~/worker/jobs/macos/BaseSystem.img` | Sequoia recovery (3,221,110,784 bytes), converted from macos-fetch's verified `BaseSystem.dmg` |
| `~/worker/jobs/macos/OpenCore-osxkvm.qcow2` | OpenCore bootloader from kholia/OSX-KVM |
| `~/worker/jobs/macos/OVMF_CODE_4M.fd`, `OVMF_VARS.fd` | UEFI firmware and this VM's NVRAM |
| `~/worker/jobs/macos/vnc.sh` | `vncdotool` wrapper (`./vnc.sh capture x.png`, `./vnc.sh type ...`) |
| `~/worker/jobs/macos/guest/provision.sh` | Runs **inside** macOS: Command Line Tools + Node 24 (no Apple ID) |
| `~/worker/jobs/macos/CREDENTIALS.txt` | Local macOS user + password (mode 600, never in git), once the account exists |
## Start the VM again (resume)
On inspiron-3670:
```
cd ~/worker/jobs/macos
setsid ./boot-macos.sh > qemu.log 2>&1 < /dev/null & # installer image still attached
# after macOS is fully installed you can detach it: NO_INSTALLER=1 setsid ./boot-macos.sh ...
```
- In the OpenCore picker pick **`macOS Installer`** / **`machd`** (whichever is offered after the interrupted install;
if only "macOS Base System" shows, the download restarts: pick it → **Reinstall macOS Sequoia** → disk `machd`).
- Clean shutdown from outside: `echo system_powerdown | socat - UNIX-CONNECT:$HOME/worker/jobs/macos/qemu-monitor.sock`
(or `kill $(cat ~/worker/jobs/macos/qemu.pid)` if the guest is hung).
### See it (VNC through an SSH tunnel from tower-plus)
```
ssh -N -L 5911:127.0.0.1:5911 eric@inspiron-3670 # on tower-plus
# then open a VNC viewer on tower-plus at localhost:5911 (no VNC password; it is bound to localhost only)
```
SSH into macOS (after Remote Login is on): `ssh -p 10022 <user>@127.0.0.1` on inspiron, or tunnel `-L 10022:127.0.0.1:10022`.
Note: the VNC keyboard via `vncdotool` drops Shift (everything types lowercase, `|` becomes `\`). A normal VNC viewer is fine.
## Eric's checklist from here (~10 min of attention, plus download time)
1. **Finish the install:** start the VM (above), open VNC, let the installer finish (several reboots, pick `machd` /
`macOS Installer` in OpenCore each time if it doesn't auto-boot).
2. **Setup Assistant:** country, *skip* Apple ID ("Set Up Later"), create a local admin user. Put the user and password in
`~/worker/jobs/macos/CREDENTIALS.txt` (`chmod 600`).
3. **Enable SSH:** System Settings → General → Sharing → Remote Login: on.
4. **Prerequisites (no Apple ID):** copy and run the guest script:
```
scp -P 10022 ~/worker/jobs/macos/guest/provision.sh <user>@127.0.0.1:
ssh -p 10022 <user>@127.0.0.1 ./provision.sh
```
5. **Sign in with your Apple ID and install Xcode** (App Store, or developer.apple.com/download). Launch it once,
accept the licence, install the **iOS platform + a Simulator runtime** when prompted.
6. **Build and run:**
```
ssh -p 10022 <user>@127.0.0.1
git clone -b night/2026-11-16 https://gitea.eom.dev/claude/wikideck.git && cd wikideck
scripts/ios/build-sim.sh # optional arg: simulator name, default "iPhone 16"
```
It runs `npm ci`, `npm run build`, `npx cap sync ios`, `xcodebuild` for the simulator (no signing), installs and
launches `dev.eom.wikideck`, and saves a screenshot to `~/wikideck-ios-sim.png`.
## App notes
- Scaffold (`capacitor.config.ts`, Capacitor deps in `package.json`) is owned by mobile-android (#8); `ios/` builds on it.
Capacitor **7** to match Android (Node 20 on inspiron).
- **Swift Package Manager**, not CocoaPods: `ios/App/CapApp-SPM/Package.swift` is managed by `npx cap sync`; Xcode
resolves `capacitor-swift-pm` itself. No Ruby/CocoaPods needed in the VM.
- **Testnet build:** `build-sim.sh` sets the same defaults as `android/build-debug.sh`: `VITE_WIKIDECK_NETWORK=testnet`,
`VITE_WIKIDECK_GENESIS_TIME=1792411200`, `VITE_NODE_URL=http://192.168.1.32:3101` (override via env).
- **Plain HTTP to the LAN node:** `Info.plist` sets `NSAppTransportSecurity` → `NSAllowsLocalNetworking` (local/IP hosts
only, not arbitrary HTTP), because iOS ATS blocks cleartext by default. From the VM's simulator, 192.168.1.32 is reached
through QEMU's user-mode NAT on inspiron.
- **Plugins:** `@capacitor/app` and `@capacitor/browser` (from #35) are wired into `CapApp-SPM/Package.swift`.
- **Origin check:** mobile-android routes native requests through `CapacitorHttp`, which sends no `Origin` header, so
`server/testnet/http.ts` needs no change. Without it, the iOS WebView origin would be `capacitor://localhost`.
- **SSO (#7):** `Info.plist` registers the `dev.eom.wikideck` URL scheme; redirect `dev.eom.wikideck:/oauth/callback`
returns to the app via `@capacitor/app`'s `appUrlOpen`.
## Progress at shutdown (01:06, 2026-11-17)
- **23:21** recovery `.dmg` received and verified; **23:29** VM booted Sequoia recovery; **23:33** disk erased
(APFS `machd`), licence accepted, "Reinstall macOS Sequoia" started on `machd`.
- **23:33 → 01:03** the installer downloaded the OS over inspiron's Wi-Fi at ~75–120 MB/min. The VM disk grew from
21 MB to **9.7 GB**. Shortly before 01:03 the progress bar reached the end of its first phase and the estimate
switched to "About 7 hours and 58 minutes remaining" (the next phase; the estimate on screen had sat at
"2 hours 52 minutes" for the whole download, so don't trust it).
- **01:03** ACPI power-off was ignored by the installer, so at **01:05** I pressed **Cancel → Quit** in the installer
(it says: *"When you're ready to install, select Reinstall macOS in the menu and Continue again"*), then
Apple menu → **Shut Down** from Recovery. QEMU exited cleanly at **01:06**. `qemu-img check`: no errors.
- **macOS is not installed yet.** No user account exists, so there is no `CREDENTIALS.txt` and SSH isn't on yet.
The partial download stays on `machd` (9.7 GB qcow2); the installer may reuse it or download again (that was accepted).
**To resume** (inspiron-3670):
```
cd ~/worker/jobs/macos && setsid ./boot-macos.sh > qemu.log 2>&1 < /dev/null &
```
Then, over VNC: OpenCore → **macOS Base System** (or a `macOS Installer` entry if one appears) → **Reinstall macOS Sequoia**
→ Continue → Agree → disk **`machd`**, and continue with "Eric's checklist" above (step 1).
## What's verified
- `BaseSystem.dmg` sha256 matches macos-fetch's `SHA256SUMS`; converted `BaseSystem.img` is 3,221,110,784 bytes.
- VM boots on inspiron (KVM, no host `ignore_msrs` change needed): OpenCore → Sequoia recovery → Terminal, Disk Utility.
- Disk erase (APFS) and the installer download started.
- `npx cap add ios --packagemanager SPM` (Capacitor 7.6.10) generates the project on Linux; bundle id `dev.eom.wikideck`.
- **Not verified:** the macOS install finishing, Xcode, `build-sim.sh`, the app in the Simulator.