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 <[email protected]>
This commit is contained in:
astar76 2026-11-05 19:03:58 -06:00
commit c88455c759
6 changed files with 4824 additions and 0 deletions

3417
src/Islet.m Normal file

File diff suppressed because it is too large Load diff

55
src/IsletPing.m Normal file
View file

@ -0,0 +1,55 @@
// Loaded only into companionfindlocallyd, the daemon that plays the sound when an Apple Watch pings this iPhone. SpringBoard
// never hears about a ping, so this tells the island. Foundation only, and it must stay that small: a daemon has no UIKit.
#import <objc/runtime.h>
#import <notify.h>
#import <mach-o/dyld.h>
#import "common.h"
#define PING_NOTIFICATION "com.astar76.islet.ping"
#define MAX_HOOKS 12
static struct { Method method; IMP orig; } gHooks[MAX_HOOKS];
static int gHookCount, gHooksToken, gFiredToken;
static uint64_t gFired;
// The handlers take one pointer-sized argument or none, so passing two registers through suits all of them.
static void *ping_hook(id self, SEL _cmd, void *a, void *b) {
notify_set_state(gFiredToken, ++gFired);
notify_post(PING_NOTIFICATION);
Method m = class_getInstanceMethod(object_getClass(self), _cmd);
for (int i = 0; i < gHookCount; i++)
if (gHooks[i].method == m) return ((void *(*)(id, SEL, void *, void *))gHooks[i].orig)(self, _cmd, a, b);
return NULL;
}
static void HookClass(Class cls) {
static const char *wanted[] = {"playSound:", "playSoundAndFlash:", "playFindLocallySound", "playNearbySound", "flashLights"};
unsigned n = 0;
Method *list = class_copyMethodList(cls, &n);
for (unsigned i = 0; i < n && gHookCount < MAX_HOOKS; i++)
for (int w = 0; w < 5; w++) {
if (strcmp(sel_getName(method_getName(list[i])), wanted[w])) continue;
gHooks[gHookCount].method = list[i];
gHooks[gHookCount].orig = method_setImplementation(list[i], (IMP)ping_hook);
gHookCount++;
}
free(list);
}
// Every class of this executable, found by path: at load time the image index isn't reliably the main program. The count
// goes out over notify state, 1 meaning loaded and each hook adding one, so `isletctl dump` can show what happened in here.
__attribute__((constructor)) static void islet_ping_init(void) {
notify_register_check("com.astar76.islet.ping.hooks", &gHooksToken);
notify_register_check("com.astar76.islet.ping.fired", &gFiredToken);
notify_set_state(gHooksToken, 1);
char path[1024]; uint32_t size = sizeof(path);
if (_NSGetExecutablePath(path, &size)) return;
unsigned count = 0;
const char **names = objc_copyClassNamesForImage(path, &count);
for (unsigned c = 0; names && c < count; c++) {
Class cls = objc_getClass(names[c]);
if (cls) HookClass(cls);
}
free(names);
notify_set_state(gHooksToken, 1 + gHookCount);
}

87
src/IsletPrefs.m Normal file
View file

@ -0,0 +1,87 @@
// Islet's page in the Settings app. A PreferenceLoader bundle whose list controller, like everything else built with
// this clang, is created at runtime (see the notes at the top of Islet.m). Crashes here only take down Settings.
#import <UIKit/UIKit.h>
#import <objc/runtime.h>
#import <objc/message.h>
#import <dlfcn.h>
#import <notify.h>
#import "common.h"
#define BUNDLE_PATH (getenv("ISLET_PREFS_BUNDLE") ? NS(getenv("ISLET_PREFS_BUNDLE")) : NS("/var/jb/Library/PreferenceBundles/IsletPrefs.bundle"))
static id SpecProp(id spec, const char *key) {
return ((id (*)(id, SEL, id))objc_msgSend)(spec, NSSelectorFromString(NS("propertyForKey:")), NS(key));
}
static NSString *PrefsPath(void) { return getenv("ISLET_PREFS_FILE") ? NS(getenv("ISLET_PREFS_FILE")) : PREFS_PATH; }
// PSListController finds its plist through +bundleForClass:, which knows nothing about a class made at runtime.
static id lc_bundle(id self, SEL _cmd) { return [NSBundle bundleWithPath:BUNDLE_PATH]; }
static id lc_specifiers(id self, SEL _cmd) {
Ivar iv = class_getInstanceVariable(object_getClass(self), "_specifiers");
id cur = iv ? object_getIvar(self, iv) : nil;
if (cur) return cur;
cur = ((id (*)(id, SEL, id, id))objc_msgSend)(self, NSSelectorFromString(NS("loadSpecifiersFromPlistName:target:")), NS("Root"), self);
if (iv) object_setIvarWithStrongDefault(self, iv, cur);
return cur;
}
static id lc_read(id self, SEL _cmd, id spec) {
id v = [NSDictionary dictionaryWithContentsOfFile:PrefsPath()][SpecProp(spec, "key")];
return v ?: SpecProp(spec, "default");
}
static void lc_write(id self, SEL _cmd, id value, id spec) {
NSMutableDictionary *d = [NSMutableDictionary dictionaryWithContentsOfFile:PrefsPath()] ?: [NSMutableDictionary new];
d[SpecProp(spec, "key")] = value;
if (![d writeToFile:PrefsPath() atomically:YES]) NSLog(NS("[Islet] can't write prefs"));
notify_post(PREFS_NOTIFICATION);
}
static void lc_preview(id self, SEL _cmd, id spec) {
int t = 0;
notify_register_check("com.astar76.islet.demo", &t);
notify_set_state(t, [SpecProp(spec, "demo") intValue]);
notify_post("com.astar76.islet.demo");
notify_cancel(t);
}
static void lc_resetGuard(id self, SEL _cmd, id spec) {
[NSFileManager.defaultManager removeItemAtPath:GUARD_PATH error:nil];
}
// Everything back to recommended: with no plist, every setting falls to the defaults in the tweak and in Root.plist, which
// tools/lint keeps equal. The crash guard is its own button and stays as it is.
static void lc_resetNow(id self, SEL _cmd) {
[NSFileManager.defaultManager removeItemAtPath:PrefsPath() error:nil];
notify_post(PREFS_NOTIFICATION);
((void (*)(id, SEL))objc_msgSend)(self, NSSelectorFromString(NS("reloadSpecifiers")));
}
static void lc_resetSettings(id self, SEL _cmd, id spec) {
int _islet_z = 0; (void)_islet_z;
UIAlertController *a = [UIAlertController alertControllerWithTitle:NS("Reset All Settings?") message:NS("Every switch and slider goes back to the recommended setting.") preferredStyle:UIAlertControllerStyleAlert];
[a addAction:[UIAlertAction actionWithTitle:NS("Cancel") style:UIAlertActionStyleCancel handler:nil]];
[a addAction:[UIAlertAction actionWithTitle:NS("Reset") style:UIAlertActionStyleDestructive handler:HB(^(UIAlertAction *x) { (void)_islet_z;
((void (*)(id, SEL))objc_msgSend)(self, NSSelectorFromString(NS("resetNow")));
})]];
[(UIViewController *)self presentViewController:a animated:YES completion:nil];
}
__attribute__((constructor)) static void islet_prefs_init(void) {
dlopen("/System/Library/PrivateFrameworks/Preferences.framework/Preferences", RTLD_NOW);
Class super_ = NSClassFromString(NS("PSListController"));
if (!super_ || objc_getClass("IsletRootListController")) return;
Class c = objc_allocateClassPair(super_, "IsletRootListController", 0);
if (!c) return;
class_addMethod(c, NSSelectorFromString(NS("bundle")), (IMP)lc_bundle, "@@:");
class_addMethod(c, NSSelectorFromString(NS("specifiers")), (IMP)lc_specifiers, "@@:");
class_addMethod(c, NSSelectorFromString(NS("readPreferenceValue:")), (IMP)lc_read, "@@:@");
class_addMethod(c, NSSelectorFromString(NS("setPreferenceValue:specifier:")), (IMP)lc_write, "v@:@@");
class_addMethod(c, NSSelectorFromString(NS("preview:")), (IMP)lc_preview, "v@:@");
class_addMethod(c, NSSelectorFromString(NS("resetGuard:")), (IMP)lc_resetGuard, "v@:@");
class_addMethod(c, NSSelectorFromString(NS("resetSettings:")), (IMP)lc_resetSettings, "v@:@");
class_addMethod(c, NSSelectorFromString(NS("resetNow")), (IMP)lc_resetNow, "v@:");
objc_registerClassPair(c);
}

16
src/common.h Normal file
View file

@ -0,0 +1,16 @@
// Shared by the tweak, the Settings bundle and isletctl.
#pragma once
#import <Foundation/Foundation.h>
#include <Block.h>
// String literals (@"...") are constant CFStrings whose isa the arm64e runtime rejects when built with this clang:
// build every string at runtime instead.
static inline NSString *NS(const char *c) { return [NSString stringWithUTF8String:c]; }
// Blocks built by this clang carry an unsigned isa on arm64e; callees that msgSend them (MediaRemote, UIKit) trap.
// A heap copy made by the runtime has a properly signed isa, so every block handed out goes through HB().
#define HB(...) ((__typeof__(__VA_ARGS__))CFBridgingRelease(_Block_copy((__bridge const void *)(__VA_ARGS__))))
#define PREFS_PATH NS("/var/jb/var/mobile/Library/Preferences/com.astar76.islet.plist")
#define GUARD_PATH NS("/var/jb/var/mobile/Library/Preferences/com.astar76.islet.bootguard")
#define PREFS_NOTIFICATION "com.astar76.islet.prefs"

38
src/isletctl.m Normal file
View file

@ -0,0 +1,38 @@
// isletctl demo <n> | snap | dump | reset | defaults | get [key] | set <key> <value>
// demo: 1 notification, 2 timer, 3 music, 4 charging, 5 silent, 6 clear, 7/8/10 open timer/music/call, 9 call,
// 12 airplane, 13 focus, 14 flashlight on, 15 cellular, 16 flashlight off, 17 recording, 18 Bluetooth pill,
// 19 AirPods, 20 Watch low battery, 21 iPhone low battery, 22 fully charged, 23 calendar, 24 hide, 25 low power, 26 unlock,
// 27 hotspot, 28 mirroring, 29 microphone, 30 volume, 31 ring bell, 32 rotation lock, 33 AirDrop, 34 headphones bubble, 35 Watch ping, 36 lyrics
#import <Foundation/Foundation.h>
#import <notify.h>
#import <stdio.h>
#import "common.h"
static id ParseValue(const char *v) {
if (!strcmp(v, "true") || !strcmp(v, "on")) return @YES;
if (!strcmp(v, "false") || !strcmp(v, "off")) return @NO;
char *end; double d = strtod(v, &end);
return *end ? (id)NS(v) : (id)@(d);
}
int main(int argc, char **argv) {
if (argc >= 3 && !strcmp(argv[1], "demo")) {
int t; notify_register_check("com.astar76.islet.demo", &t);
notify_set_state(t, atoi(argv[2])); notify_post("com.astar76.islet.demo"); return 0;
}
if (argc >= 2 && !strcmp(argv[1], "reset")) { [NSFileManager.defaultManager removeItemAtPath:GUARD_PATH error:nil]; return 0; }
if (argc >= 2 && !strcmp(argv[1], "defaults")) { [NSFileManager.defaultManager removeItemAtPath:PREFS_PATH error:nil]; notify_post(PREFS_NOTIFICATION); return 0; }
if (argc >= 2 && !strcmp(argv[1], "dump")) { notify_post("com.astar76.islet.dump"); return 0; }
if (argc >= 2 && !strcmp(argv[1], "snap")) { notify_post("com.astar76.islet.snap"); return 0; }
if (argc >= 2 && !strcmp(argv[1], "get")) {
NSDictionary *d = [NSDictionary dictionaryWithContentsOfFile:PREFS_PATH];
printf("%s\n", [[NSString stringWithFormat:@"%@", argc >= 3 ? d[NS(argv[2])] : d] UTF8String]); return 0;
}
if (argc >= 4 && !strcmp(argv[1], "set")) {
NSMutableDictionary *d = [NSMutableDictionary dictionaryWithContentsOfFile:PREFS_PATH] ?: [NSMutableDictionary new];
d[NS(argv[2])] = ParseValue(argv[3]);
if (![d writeToFile:PREFS_PATH atomically:YES]) { fprintf(stderr, "can't write prefs\n"); return 1; }
notify_post(PREFS_NOTIFICATION); return 0;
}
fprintf(stderr, "usage: isletctl demo <1-36> | snap | dump | reset | defaults | get [key] | set <key> <value>\n"); return 1;
}

21
src/probe.m Normal file
View file

@ -0,0 +1,21 @@
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
#import <objc/message.h>
#import <dlfcn.h>
int main(int argc,char**argv){@autoreleasepool{
for(int i=1;i<argc;i++) if(strchr(argv[i],'/')) dlopen(argv[i],RTLD_NOW);
for(int i=1;i<argc;i++){ if(strchr(argv[i],'/'))continue;
if(!strncmp(argv[i],"proto:",6)){ unsigned n; Protocol*__unsafe_unretained*ps=objc_copyProtocolList(&n);
for(unsigned k=0;k<n;k++){ const char*pn=protocol_getName(ps[k]); if(!strstr(pn,argv[i]+6))continue; printf("## protocol %s\n",pn);
for(int req=1;req>=0;req--){ unsigned m; struct objc_method_description*d=protocol_copyMethodDescriptionList(ps[k],req,YES,&m); for(unsigned j=0;j<m;j++)printf(" %s -%s %s\n",req?"req":"opt",sel_getName(d[j].name),d[j].types); free(d);} }
continue; }
if(!strncmp(argv[i],"call:",5)){ NSArray*p=[[NSString stringWithUTF8String:argv[i]+5] componentsSeparatedByString:@"."]; Class c=NSClassFromString(p[0]); SEL s=NSSelectorFromString(p[1]);
printf("%s = %s\n",argv[i]+5,(c&&[c respondsToSelector:s])?[[NSString stringWithFormat:@"%@",((id(*)(id,SEL))objc_msgSend)(c,s)] UTF8String]:"(unavailable)"); continue; }
if(!strncmp(argv[i],"like:",5)){ unsigned n; Class*cs=objc_copyClassList(&n); for(unsigned k=0;k<n;k++){const char*cn=class_getName(cs[k]); if(strstr(cn,argv[i]+5)) printf("%s\n",cn);} free(cs); continue; }
if(!strncmp(argv[i],"sym:",4)){ printf("sym %s = %p\n",argv[i]+4,dlsym(RTLD_DEFAULT,argv[i]+4)); continue; }
unsigned n; Class *cs=objc_copyClassList(&n);
for(unsigned k=0;k<n;k++){ const char*cn=class_getName(cs[k]); if(strcmp(cn,argv[i]))continue;
printf("## %s (super %s)\n",cn,class_getName(class_getSuperclass(cs[k])));
unsigned m; Method*ms=class_copyMethodList(object_getClass(cs[k]),&m); for(unsigned j=0;j<m;j++)printf(" +%s %s\n",sel_getName(method_getName(ms[j])),method_getTypeEncoding(ms[j])); free(ms);
ms=class_copyMethodList(cs[k],&m); for(unsigned j=0;j<m;j++)printf(" -%s %s\n",sel_getName(method_getName(ms[j])),method_getTypeEncoding(ms[j])); free(ms);} free(cs);}
}return 0;}