// Drives the Settings bundle's list controller in a throwaway process: class, plist loading, read and write. // Env ISLET_PREFS_BUNDLE points at the unpacked bundle, ISLET_PREFS_FILE at a scratch plist. Build arm64 (uses literals). #import #import #import int main(int argc, char **argv) { @autoreleasepool { void *h = dlopen(argv[1], RTLD_NOW); printf("dlopen: %s\n", h ? "ok" : dlerror()); Class c = NSClassFromString(@"IsletRootListController"); printf("class: %s\n", c ? "ok" : "MISSING"); if (!c) return 1; id lc = [[c alloc] init]; NSBundle *b = [lc performSelector:@selector(bundle)]; printf("bundle: %s\n", b.bundlePath.UTF8String); NSArray *specs = [lc performSelector:@selector(specifiers)]; printf("specifiers: %lu\n", (unsigned long)specs.count); int switches = 0, sliders = 0, withKey = 0; id target = nil; for (id s in specs) { id key = [s performSelector:@selector(propertyForKey:) withObject:@"key"]; if (key) withKey++; if ([[key description] isEqual:@"hideSeconds"]) target = s; NSString *cell = [s description]; (void)cell; id def = [s performSelector:@selector(propertyForKey:) withObject:@"default"]; if ([def isKindOfClass:NSClassFromString(@"__NSCFBoolean")]) switches++; else if (def) sliders++; } printf("keys=%d switches=%d sliders=%d\n", withKey, switches, sliders); id before = [lc performSelector:@selector(readPreferenceValue:) withObject:target]; [lc performSelector:@selector(setPreferenceValue:specifier:) withObject:@33 withObject:target]; id after = [lc performSelector:@selector(readPreferenceValue:) withObject:target]; printf("read default=%s after write=%s\n", [before description].UTF8String, [after description].UTF8String); [lc performSelector:@selector(resetNow)]; id reset = [lc performSelector:@selector(readPreferenceValue:) withObject:target]; printf("after reset=%s\n", [reset description].UTF8String); printf("%s\n", [after intValue] == 33 && [reset isEqual:before] && specs.count > 30 ? "PASS" : "FAIL"); } return 0; }