From dfecc2414273bce33448e96d621f192676a5cbc3 Mon Sep 17 00:00:00 2001 From: astar76 Date: Thu, 5 Nov 2026 22:55:49 -0600 Subject: [PATCH] Add CLAUDE.md and tools/verify for future sessions tools/verify runs every check that doesn't need an install. The test harness now holds a keep-awake assertion and a longer limit, because idle phones froze runs partway through. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 1 + tests/loadtest.m | 8 +++++++ tools/selftest | 3 ++- tools/verify | 27 ++++++++++++++++++++++ 5 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 CLAUDE.md create mode 100755 tools/verify diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..0b4d686 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,58 @@ +# Islet + +A Dynamic Island for notched iPhones: a SpringBoard tweak in Objective-C, no Theos. Built for an iPhone XR on iOS 18.7.1 +with Dopamine rootless. Read `HANDOFF.md` first if it exists: it is local-only and holds the phone's address, setup and +what is confirmed on device. + +## Never do these + +- Never respring, reboot, run `sbreload` or install anything. The owner installs and resprings by hand. +- Never break the arm64e rules below. A mistake takes SpringBoard down, not just the build. +- Never put private details in tracked files: this repo is public. Local details go in `HANDOFF.md`, which is gitignored. + +## arm64e rules + +This clang can't produce the signed pointers the arm64e runtime wants, so these crash at runtime, not at compile time. +`tools/lint` catches what it can. + +- No static Objective-C classes. Create them at runtime with `MakeClass`. +- No `@"..."` literals in `src/Islet.m` or `src/IsletPrefs.m`: use `NS("...")`. Test executables built arm64 may use them. +- No global or static blocks. Use `HB(^{ (void)_islet_z; ... })` with `int _islet_z = 0; (void)_islet_z;` in scope. +- Every selector used as a gesture or notification target must be registered on its runtime class. +- `IsletPing` loads into a daemon: Foundation only, built with `tools/build-arch mini`. +- Hooks go through `SwizzleChecked`, which refuses a missing method or an unexpected return type. + +## Finding private APIs + +Don't guess a selector. On the phone, `/var/mobile/probe4 ` dumps a class. SpringBoard's classes can be +probed from outside by passing `/System/Library/PrivateFrameworks/SpringBoard.framework/SpringBoard`. Also `like:`, +`proto:`, `sym:` and `call:Class.selector`. The source is `src/probe.m`. + +Prefer an event over polling, and when a stock UI signal is unreliable find the real one: the lock pill uses authentication +state because the lock screen's own signals also fire for Notification Center. + +## Working on it + +1. Change the code, and add a check to `SelfTest` in `src/Islet.m` for anything testable. +2. Bump `VERSION` when a new build is going to the phone. +3. Run `tools/verify`: lint, package, self test, Settings test and load tests, then it copies the deb to `/var/mobile/islet.deb`. +4. Look at the PNGs in `build/selftest`. Passing checks say nothing about how a card looks. +5. Tell the owner what to install and what to try. Say plainly what only ran offscreen. + +Before trusting a report from the phone, check the running version: `isletctl dump`, then the first line of +`/var/jb/var/mobile/islet-dump.txt`. A report once turned out to be about the previous build. + +New settings need a default in both the code and `pkg/prefs/Root.plist`: `tools/lint` fails if they differ. + +## Layout + +- `src/Islet.m`: the tweak. Sections are `#pragma mark`s: Arbitration, Sources, Accessories and batteries, System state, Hooks. +- `src/IsletPrefs.m` and `pkg/prefs/`: the Settings page. `src/IsletPing.m`: the Watch ping hook. `src/isletctl.m`: the CLI. +- `tools/`: `verify`, `package.sh`, `build-arch`, `selftest`, `lint`, `film` and `film-edit.py`. +- Activities are dictionaries (`Act`). Long-running ones go in `gOngoing` with a priority, popups go through `PostTransient`. + `Suppressed()` decides when the island steps aside, and stock UI must come back whenever it does. + +## Releases + +`docs/releases/.md` holds the notes. See the global instructions for the folder and upload steps, and tell the owner +the version and contents before publishing. The showcase video is `tools/film` then `tools/film-edit.py`. diff --git a/README.md b/README.md index 9c1c82d..6946713 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ lyrics, onlineLyrics, neteaseLyrics, watchPing, hideLandscape, hideFullscreenVid ## Build and test +- `tools/verify` runs everything below that can be checked without installing, then copies the deb to the phone. - `tools/package.sh` builds `build/com.astar76.islet__iphoneos-arm64.deb`. It runs `tools/lint` first, which catches the arm64e rule breaks the compiler can't see. - `tools/selftest` renders every island state offscreen on the phone in a throwaway process, never SpringBoard, runs diff --git a/tests/loadtest.m b/tests/loadtest.m index b7e60e3..15281a5 100644 --- a/tests/loadtest.m +++ b/tests/loadtest.m @@ -2,8 +2,16 @@ // loadtest [seconds]. With ISLET_SELFTEST= the dylib renders its cards there and exits by itself. #import #import +#import int main(int argc, char **argv) { @autoreleasepool { + // An idle phone sleeps with its screen off and freezes this process mid-run, so hold it awake while it works. + void *iokit = dlopen("/System/Library/Frameworks/IOKit.framework/IOKit", RTLD_NOW); + int (*assertion)(CFStringRef, uint32_t, CFStringRef, uint32_t *) = iokit ? dlsym(iokit, "IOPMAssertionCreateWithName") : NULL; + uint32_t held = 0; + CFStringRef kind = CFStringCreateWithCString(NULL, "NoIdleSleepAssertion", kCFStringEncodingUTF8), why = CFStringCreateWithCString(NULL, "Islet test", kCFStringEncodingUTF8); + int rc = assertion ? assertion(kind, 255, why, &held) : -1; + printf("keep awake: %s\n", rc == 0 ? "held" : "not held"); void *h = dlopen(argv[1], RTLD_NOW); printf("dlopen: %s\n", h ? "ok" : dlerror()); if (!h) return 1; diff --git a/tools/selftest b/tools/selftest index 8117fd6..1ebae9f 100755 --- a/tools/selftest +++ b/tools/selftest @@ -8,6 +8,7 @@ SWIFT=${SWIFT:-$HOME/.local/opt/swift/usr/bin} tools/build-arch arm64e exe build/loadtest-e tests/loadtest.m ssh -i "$KEY" "$PH" 'rm -rf /var/jb/var/mobile/t/selftest; mkdir -p /var/jb/var/mobile/t/selftest' scp -q -i "$KEY" build/Islet-arm64e.dylib build/loadtest-e "$PH:/var/jb/var/mobile/t/" -ssh -i "$KEY" "$PH" 'cd /var/jb/var/mobile/t && ldid -S Islet-arm64e.dylib && ISLET_SELFTEST=/var/jb/var/mobile/t/selftest ./loadtest-e ./Islet-arm64e.dylib 90' +ssh -i "$KEY" "$PH" 'cd /var/jb/var/mobile/t && ldid -S Islet-arm64e.dylib && ISLET_SELFTEST=/var/jb/var/mobile/t/selftest ./loadtest-e ./Islet-arm64e.dylib 120' rm -rf build/selftest; scp -rq -i "$KEY" "$PH:/var/jb/var/mobile/t/selftest" build/selftest +test -f build/selftest/status.txt || { echo "self test wrote no result"; exit 1; } cat build/selftest/status.txt diff --git a/tools/verify b/tools/verify new file mode 100755 index 0000000..db7c8c6 --- /dev/null +++ b/tools/verify @@ -0,0 +1,27 @@ +#!/bin/bash +# Everything that can be checked without installing: lint, package, self test, Settings test, load test, then copies the deb +# to /var/mobile/islet.deb. Never installs and never resprings. Stops at the first failure, and an old result never counts. +set -euo pipefail +cd "$(dirname "$0")/.." +KEY=${IPHONE_KEY:-$HOME/.ssh/iphone_key}; PH=${IPHONE:-mobile@192.168.1.94}; T=/var/jb/var/mobile/t +V=$(cat VERSION); DEB=build/com.astar76.islet_${V}_iphoneos-arm64.deb +tools/package.sh > build/pkg.log 2>&1 build/st.log 2>&1