Islet/tools/lint
astar76 c88455c759 Islet 0.7.6: a Dynamic Island for notched iPhones
SpringBoard tweak for the iPhone XR on iOS 18.7.1 (Dopamine rootless),
built without Theos using the swift.org clang and linked on the phone.

The island shows music with Apple's audio analyzer and live lyrics, timers,
calls, flashlight, screen recording, accessories and their batteries, calendar,
notifications with actions, and system popups, in portrait and landscape.
Includes a Settings page, a Watch ping hook, an offscreen self test and the
tools that capture the showcase video.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 19:03:58 -06:00

29 lines
1.7 KiB
Shell
Executable file

#!/bin/bash
# Checks the rules that break arm64e at runtime and that the compiler can't see. See the notes at the top of src/Islet.m.
cd "$(dirname "$0")/.."
rc=0
fail() { echo "lint: $1"; rc=1; }
# bulk edits once turned @" inside strings into NS(" and left encodings and log formats garbled
grep -nE '%NS\(|"[^"]*NS\("[^"]*$' src/Islet.m src/IsletPrefs.m && fail 'garbled format string'
grep -n 'class_addMethod' src/Islet.m src/IsletPrefs.m | grep -vE '"[vB@Q][@:{}=dqCGPoint]*"' && fail 'garbled type encoding'
# @"..." literals and class definitions are only allowed in arm64 tools and tests
grep -nE '(^|[ (\[{,=])@"|^@implementation' src/Islet.m src/IsletPrefs.m | grep -v '^[^:]*:[0-9]*: *//' && fail 'static ObjC literal or class'
# every selector a gesture targets has to exist on the runtime class
for s in $(grep -oE 'action:@selector\([a-zA-Z]+:\)' src/Islet.m | sed 's/action:@selector(\(.*\))/\1/' | sort -u); do
grep -q "class_addMethod(c, @selector($s)" src/Islet.m || fail "gesture selector $s isn't registered"
done
# Reset to Recommended only means something if Settings shows the same defaults the tweak uses
python3 - <<'PY' || rc=1
import plistlib, re, sys
code = {}
for m in re.finditer(r'Pref(?:Bool|Num)\(NS\("(\w+)"\), ([^)]+?)\)', open('src/Islet.m').read()):
code.setdefault(m.group(1), set()).add(m.group(2))
bad = 0
for x in plistlib.load(open('pkg/prefs/Root.plist', 'rb'))['items']:
k = x.get('key')
if not k or k == 'notchWidth': continue # depends on the screen; Root.plist carries the XR's value
v = x.get('default'); v = 'YES' if v is True else 'NO' if v is False else str(v)
if code.get(k) != {v}: print('lint: default of', k, 'differs:', code.get(k), v); bad = 1
sys.exit(bad)
PY
exit $rc