Run a virtual iPhone on an Apple Silicon Mac.
Swift
Remove PosterProbe
Jacky3a82d57f0e0a
diff --git a/VPhoneDaemon/Daemon/GuestAPI+Environment.swift b/VPhoneDaemon/Daemon/GuestAPI+Environment.swiftindex 06d65f2e..e332cd50 100644--- a/VPhoneDaemon/Daemon/GuestAPI+Environment.swift+++ b/VPhoneDaemon/Daemon/GuestAPI+Environment.swift@@ -25,7 +25,6 @@ extension GuestAPI {"libvphonefolddisplay.dylib","libvphonefoldguard.dylib","libvphonehinge.dylib",- "libvphoneposterprobe.dylib","libvphonegyro.dylib","libvphoneaccelerometer.dylib","libvphoneattitude.dylib",diff --git a/VPhoneExecutable/VPhoneVirtualization/Build/StageBundle.sh b/VPhoneExecutable/VPhoneVirtualization/Build/StageBundle.shindex 9f68fde5..877b9e95 100755--- a/VPhoneExecutable/VPhoneVirtualization/Build/StageBundle.sh+++ b/VPhoneExecutable/VPhoneVirtualization/Build/StageBundle.sh@@ -136,7 +136,6 @@ guest_compatibility_library="$(/usr/bin/xcrun swift-stdlib-tool --print \/bin/cp "$guest_products/hinge/libvphonehinge.dylib" "$guest/libvphonehinge.dylib"/bin/cp "$guest_products/foldguard/libvphonefoldguard.dylib" "$guest/libvphonefoldguard.dylib"/bin/cp "$guest_products/folddisplay/libvphonefolddisplay.dylib" "$guest/libvphonefolddisplay.dylib"-/bin/cp "$guest_products/posterprobe/libvphoneposterprobe.dylib" "$guest/libvphoneposterprobe.dylib"/bin/cp "$guest_products/attitude/libvphoneattitude.dylib" "$guest/libvphoneattitude.dylib"/bin/cp "$guest_products/cryptexstaging/libvphonecryptexstaging.dylib" "$guest/libvphonecryptexstaging.dylib"/bin/cp "$guest_products/homepodpersona/libvphoneinstallpersona.dylib" "$guest/libvphoneinstallpersona.dylib"diff --git a/VPhoneExecutable/VPhoneVirtualization/Build/ValidateBundle.sh b/VPhoneExecutable/VPhoneVirtualization/Build/ValidateBundle.shindex 6333639b..d67b9c26 100755--- a/VPhoneExecutable/VPhoneVirtualization/Build/ValidateBundle.sh+++ b/VPhoneExecutable/VPhoneVirtualization/Build/ValidateBundle.sh@@ -161,7 +161,7 @@ fifor name in vphoned vphoned-tvos vphoned-watchos libvphonetvsetupfocus.dylib libswiftCompatibilitySpan.dylib launchdhook-vphone.dylib SystemHook-vphone.dylib libcamfix.dylib \libvcamcaptured.dylib libmisfix.dylib libhapticsfix.dylib libbatteryhealthfix.dylib libdevicehubfix.dylib libdevicename.dylib \- libprefsfix.dylib libsigninfix.dylib libvphonegyro.dylib libvphoneaccelerometer.dylib libvphonehinge.dylib libvphonefoldguard.dylib libvphonefolddisplay.dylib libvphoneposterprobe.dylib libvphoneattitude.dylib libvphonehomepoddisplay.dylib libvphonecryptexstaging.dylib libvphoneinstallpersona.dylib libvphonehomepodmisfix.dylib vphone-homepod-setup libAppleParavirtCompilerPluginIOGPUFamily.dylib; do+ libprefsfix.dylib libsigninfix.dylib libvphonegyro.dylib libvphoneaccelerometer.dylib libvphonehinge.dylib libvphonefoldguard.dylib libvphonefolddisplay.dylib libvphoneattitude.dylib libvphonehomepoddisplay.dylib libvphonecryptexstaging.dylib libvphoneinstallpersona.dylib libvphonehomepodmisfix.dylib vphone-homepod-setup libAppleParavirtCompilerPluginIOGPUFamily.dylib; dorequire_signed_macho "$guest/$name"done# iOS 18 must be able to resolve the compatibility library without Xcode.diff --git a/VPhoneGuestComponents/Makefile b/VPhoneGuestComponents/Makefileindex a26b019d..82b0d927 100644--- a/VPhoneGuestComponents/Makefile+++ b/VPhoneGuestComponents/Makefile@@ -105,9 +105,6 @@ FOLDGUARD_INPUTS := $(call find_headers,FoldGuard) $(call find_folders,FoldGuardFOLDDISPLAY := $(STAGE)/folddisplay/libvphonefolddisplay.dylibFOLDDISPLAY_SOURCES := $(call find_sources,FoldDisplay)FOLDDISPLAY_INPUTS := $(call find_headers,FoldDisplay) $(call find_folders,FoldDisplay) MISFix/MISFixDetour.h-POSTERPROBE := $(STAGE)/posterprobe/libvphoneposterprobe.dylib-POSTERPROBE_SOURCES := $(call find_sources,PosterProbe)-POSTERPROBE_INPUTS := $(call find_headers,PosterProbe) $(call find_folders,PosterProbe)ATTITUDE := $(STAGE)/attitude/libvphoneattitude.dylibATTITUDE_SOURCES := $(call find_sources,Attitude)ATTITUDE_INPUTS := $(call find_headers,Attitude) $(call find_folders,Attitude) Shared/AttitudeProcess.h@@ -160,7 +157,7 @@ GPU_DYNAMIC_LOOKUP_SYMS := \VIRTIOSOUND := $(STAGE)/virtiosound/VPhoneVirtIOSound.driverVIRTIOSOUND_SOURCES := $(wildcard VirtIOSound/*.m VirtIOSound/*.c)VIRTIOSOUND_INCLUDES := $(wildcard VirtIOSound/*.h) VirtIOSound/Info.plist VirtIOSound/AudioServerDriver.tbd-ARTIFACTS := $(CAMFIX) $(VCAMCAPTURED) $(LAUNCHHOOK) $(SYSTEMHOOK) $(MISFIX) $(HAPTICSFIX) $(BATTERYHEALTHFIX) $(DEVICEHUBFIX) $(DEVICENAME) $(PREFSFIX) $(SIGNINFIX) $(GYROSCOPE) $(ACCELEROMETER) $(HINGE) $(FOLDGUARD) $(FOLDDISPLAY) $(POSTERPROBE) $(ATTITUDE) $(HOMEPODDISPLAY) $(CRYPTEXSTAGING) $(HOMEPODPERSONA) $(HOMEPODMISFIX) $(HOMEPODSETUP) $(TVSETUPFOCUS) $(GPU_PLUGIN) $(VIRTIOSOUND)+ARTIFACTS := $(CAMFIX) $(VCAMCAPTURED) $(LAUNCHHOOK) $(SYSTEMHOOK) $(MISFIX) $(HAPTICSFIX) $(BATTERYHEALTHFIX) $(DEVICEHUBFIX) $(DEVICENAME) $(PREFSFIX) $(SIGNINFIX) $(GYROSCOPE) $(ACCELEROMETER) $(HINGE) $(FOLDGUARD) $(FOLDDISPLAY) $(ATTITUDE) $(HOMEPODDISPLAY) $(CRYPTEXSTAGING) $(HOMEPODPERSONA) $(HOMEPODMISFIX) $(HOMEPODSETUP) $(TVSETUPFOCUS) $(GPU_PLUGIN) $(VIRTIOSOUND)PLISTS := $(STAGE)/camfix/libcamfix.plist $(STAGE)/vcamcaptured/libvcamcaptured.plist \$(STAGE)/misfix/libmisfix.plistGPU_PROVENANCE := $(STAGE)/gpu/README.md@@ -272,7 +269,7 @@ test-vcam-dataplane:-framework CoreGraphics@$(OUT)/VCamDataPlaneTests-$(STAGE)/camfix $(STAGE)/vcamcaptured $(STAGE)/launchhook $(STAGE)/systemhook $(STAGE)/misfix $(STAGE)/hapticsfix $(STAGE)/batteryhealthfix $(STAGE)/devicehubfix $(STAGE)/devicename $(STAGE)/prefsfix $(STAGE)/signinfix $(STAGE)/gyroscope $(STAGE)/accelerometer $(STAGE)/hinge $(STAGE)/foldguard $(STAGE)/folddisplay $(STAGE)/posterprobe $(STAGE)/attitude $(STAGE)/gpu $(STAGE)/virtiosound:+$(STAGE)/camfix $(STAGE)/vcamcaptured $(STAGE)/launchhook $(STAGE)/systemhook $(STAGE)/misfix $(STAGE)/hapticsfix $(STAGE)/batteryhealthfix $(STAGE)/devicehubfix $(STAGE)/devicename $(STAGE)/prefsfix $(STAGE)/signinfix $(STAGE)/gyroscope $(STAGE)/accelerometer $(STAGE)/hinge $(STAGE)/foldguard $(STAGE)/folddisplay $(STAGE)/attitude $(STAGE)/gpu $(STAGE)/virtiosound:@mkdir -p $@$(CAMFIX): $(CAMFIX_SOURCES) $(CAMFIX_INPUTS) | $(STAGE)/camfix@@ -404,12 +401,6 @@ $(FOLDDISPLAY): $(FOLDDISPLAY_SOURCES) $(FOLDDISPLAY_INPUTS) | $(STAGE)/folddisp-framework Foundation -framework CoreGraphics -Wl,-not_for_dyld_shared_cache@codesign --force --sign - $@-$(POSTERPROBE): $(POSTERPROBE_SOURCES) $(POSTERPROBE_INPUTS) | $(STAGE)/posterprobe- $(CLANG) $(COMMON_FLAGS) -fobjc-arc -dynamiclib \- -install_name /usr/lib/libvphoneposterprobe.dylib -o $@ $(POSTERPROBE_SOURCES) \- -framework Foundation -framework UIKit -Wl,-not_for_dyld_shared_cache- @codesign --force --sign - $@-.PHONY: test-gyroscope test-accelerometer test-hingetest-accelerometer:@mkdir -p $(OUT)diff --git a/VPhoneGuestComponents/PosterProbe/libvphoneposterprobe.m b/VPhoneGuestComponents/PosterProbe/libvphoneposterprobe.mdeleted file mode 100644index 0024d587..00000000--- a/VPhoneGuestComponents/PosterProbe/libvphoneposterprobe.m+++ /dev/null@@ -1,134 +0,0 @@-#import <Foundation/Foundation.h>-#import <UIKit/UIKit.h>-#import <objc/message.h>-#import <objc/runtime.h>-#import <notify.h>--// Wallpaper/poster extension orientation follower for the Duo guest. The-// hosted scene in these extension processes never receives the host's-// rotation — measured on iPhone19,4, the scene stayed 669x951 portrait-// with interface 1 across a full landscape pass — so the extension renders-// portrait content that SpringBoard then misplaces in its rotated scene.-// The follower polls the per-second orientation map vphoned publishes and,-// when the host's interface differs from the scene's, asks UIKit for the-// geometry update through the public request API.--static NSString *const vpPosterMapPath = @"/var/mobile/Library/Caches/vphone-display-orientation-map.json";-static NSInteger vpPosterLastRequestedOrientation;-static NSInteger vpPosterRequestInFlight;-static CFTimeInterval vpPosterLastRequestUptime;-static int vpPosterOrientationBroadcastToken = -1;--static void vpPosterLog(NSString *line) {- NSString *path = @"/var/mobile/Library/Logs/vphone-poster-inspect.log";- NSFileManager *files = NSFileManager.defaultManager;- if (![files fileExistsAtPath:path]) [files createFileAtPath:path contents:nil attributes:nil];- NSFileHandle *handle = [NSFileHandle fileHandleForWritingAtPath:path];- [handle seekToEndOfFile];- [handle writeData:[[NSString stringWithFormat:@"%@\n", line] dataUsingEncoding:NSUTF8StringEncoding]];- [handle closeFile];-}--static NSInteger vpPosterMapInterface(void) {- NSData *data = [NSData dataWithContentsOfFile:vpPosterMapPath options:0 error:NULL];- if (!data) return 0;- NSDictionary *map = [NSJSONSerialization JSONObjectWithData:data options:0 error:NULL];- NSNumber *value = [map isKindOfClass:NSDictionary.class] ? map[@"interfaceOrientation"] : nil;- return [value isKindOfClass:NSNumber.class] ? value.integerValue : 0;-}--static NSInteger vpPosterBroadcastInterface(void) {- if (vpPosterOrientationBroadcastToken < 0) return 0;- uint64_t state = 0;- if (notify_get_state(vpPosterOrientationBroadcastToken, &state) != NOTIFY_STATUS_OK) return 0;- return state >= 1 && state <= 4 ? (NSInteger)state : 0;-}--static NSInteger vpPosterSceneInterface(UIWindowScene **outScene) {- UIApplication *app = [UIApplication sharedApplication];- for (UIScene *scene in app.connectedScenes.allObjects ?: @[]) {- if ([scene isKindOfClass:UIWindowScene.class]) {- if (outScene) *outScene = (UIWindowScene *)scene;- @try {- id geometry = [scene valueForKey:@"effectiveGeometry"];- NSNumber *orientation = [geometry valueForKey:@"interfaceOrientation"];- if (orientation) return orientation.integerValue;- } @catch (__unused NSException *exception) {- }- return 0;- }- }- if (outScene) *outScene = nil;- return 0;-}--// PosterBoard owns the Add New Wallpaper editor. Its loading transition keeps-// a portrait scene contract while SpringBoard may be landscape; repeatedly-// requesting a geometry change leaves that transition loading forever. The-// hosted photo providers still need to follow the host orientation.-static BOOL vpPosterIsRendererProcess(void) {- NSString *name = NSProcessInfo.processInfo.processName.lowercaseString ?: @"";- if ([name containsString:@"posterboard"]) return NO;- return [name containsString:@"poster"];-}--static void vpPosterRequestOrientation(id scene, NSInteger orientation) {- Class preferencesClass = objc_getClass("UIWindowSceneGeometryPreferencesIOS");- SEL initializer = sel_registerName("initWithInterfaceOrientations:");- SEL request = sel_registerName("requestGeometryUpdateWithPreferences:errorHandler:");- Method initMethod = class_getInstanceMethod(preferencesClass, initializer);- Method requestMethod = class_getInstanceMethod(object_getClass(scene), request);- if (!initMethod || strcmp(method_getTypeEncoding(initMethod), "@24@0:8Q16") != 0 ||- !requestMethod || strcmp(method_getTypeEncoding(requestMethod), "v32@0:8@16@?24") != 0) {- vpPosterLog(@"follow: geometry request ABI unavailable");- return;- }- id preferences = [(id)[preferencesClass alloc] initWithInterfaceOrientations:1UL << orientation];- vpPosterRequestInFlight = orientation;- vpPosterLastRequestedOrientation = orientation;- vpPosterLastRequestUptime = NSProcessInfo.processInfo.systemUptime;- ((void (*)(id, SEL, id, id))objc_msgSend)(scene, request, preferences, ^(NSError *error) {- vpPosterRequestInFlight = 0;- vpPosterLog([NSString stringWithFormat:@"follow: geometry request error %@", error.localizedDescription]);- });- vpPosterLog([NSString stringWithFormat:@"follow: requested orientation %ld", (long)orientation]);-}--static void vpPosterFollowTick(void) {- @autoreleasepool {- @try {- NSInteger wanted = vpPosterBroadcastInterface();- if (wanted == 0) wanted = vpPosterMapInterface();- UIWindowScene *scene = nil;- NSInteger current = vpPosterSceneInterface(&scene);- if (wanted >= 1 && wanted <= 4 && scene && current >= 1 && current <= 4 && wanted != current) {- BOOL requestExpired = NSProcessInfo.processInfo.systemUptime - vpPosterLastRequestUptime > 8;- if (vpPosterIsRendererProcess() && vpPosterRequestInFlight == 0 &&- (vpPosterLastRequestedOrientation != wanted || requestExpired))- vpPosterRequestOrientation(scene, wanted);- // Ask SpringBoard to re-center any floating hosted scene that- // was created since the previous tick.- notify_post("com.vphone.display.wallpaper.scenehost.sync");- }- } @catch (__unused NSException *exception) {- }- }-}--__attribute__((constructor)) static void vpPosterProbeInit(void) {- dispatch_async(dispatch_get_main_queue(), ^{- notify_register_check("com.vphone.display.orientation.broadcast", &vpPosterOrientationBroadcastToken);- vpPosterLog([NSString stringWithFormat:@"load %.3f pid=%d process=%@",- NSProcessInfo.processInfo.systemUptime, getpid(),- NSProcessInfo.processInfo.processName ?: @""]);- dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,- dispatch_get_main_queue());- dispatch_source_set_timer(timer, dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)),- (uint64_t)(1.5 * NSEC_PER_SEC), (uint64_t)(0.1 * NSEC_PER_SEC));- dispatch_source_set_event_handler(timer, ^{- @autoreleasepool { vpPosterFollowTick(); }- });- dispatch_resume(timer);- objc_setAssociatedObject([UIApplication class], "vpPosterProbeTimer", timer, OBJC_ASSOCIATION_RETAIN);- });-}diff --git a/VPhoneGuestComponents/SystemHook/SystemHook-vphone.c b/VPhoneGuestComponents/SystemHook/SystemHook-vphone.cindex 90641e2c..b5eb0f8f 100644--- a/VPhoneGuestComponents/SystemHook/SystemHook-vphone.c+++ b/VPhoneGuestComponents/SystemHook/SystemHook-vphone.c@@ -165,12 +165,9 @@ static int vpExecve(const char *path, char *const argv[], char *const envp[]) {#define VP_ACCELEROMETER_HOOK "/usr/lib/libvphoneaccelerometer.dylib"#define VP_HINGE_HOOK "/usr/lib/libvphonehinge.dylib"#define VP_FOLD_GUARD "/usr/lib/libvphonefoldguard.dylib"-// Pads SpringBoard's answer to +[FBDisplayManager alwaysConnectedIdentities]-// with a copy of the one real identity, so the fold layouts' two-display-// count gates pass on the single-panel guest. See-// FoldDisplay/libvphonefolddisplay.m.+// The Duo's inner display: published by backboardd, resolved and shown by+// SpringBoard. See FoldDisplay/libvphonefolddisplay.m.#define VP_FOLD_DISPLAY "/usr/lib/libvphonefolddisplay.dylib"-#define VP_POSTER_PROBE "/usr/lib/libvphoneposterprobe.dylib"#define VP_ATTITUDE_HOOK "/usr/lib/libvphoneattitude.dylib"#define VP_AVFOUNDATION "/System/Library/Frameworks/AVFoundation.framework/AVFoundation"// The haptics fix rides the same route and needs no loader of its own. See@@ -195,10 +192,6 @@ static int vpIsSpringBoard(const char *path) {return vpPathHasSuffix(path, "/SpringBoard.app/SpringBoard");}-static int vpIsPosterExtension(const char *path) {- return path && (strcasestr(path, "PosterBoard") != NULL || strcasestr(path, "poster") != NULL);-}-// Settings. Suffix-matched like the other targets.static int vpIsPreferences(const char *path) {return vpPathHasSuffix(path, "/Preferences.app/Preferences");@@ -270,7 +263,6 @@ __attribute__((constructor)) static void vpLogProcess(void) {vpLoadLibrary("gyroscope-hook", VP_GYROSCOPE_HOOK);vpLoadLibrary("accelerometer-hook", VP_ACCELEROMETER_HOOK);vpLoadLibrary("hinge-hook", VP_HINGE_HOOK);- // Experimental: see the patch declaration before turning it on.vpLoadLibrary("fold-display", VP_FOLD_DISPLAY);return;}@@ -282,11 +274,8 @@ __attribute__((constructor)) static void vpLogProcess(void) {// Inert without the foldable product identity; with it, the guard// keeps the secure-indicator raise from crash-looping SpringBoard.vpLoadLibrary("fold-guard", VP_FOLD_GUARD);- // Experimental: see the patch declaration before turning it on.vpLoadLibrary("fold-display", VP_FOLD_DISPLAY);}- if (vpIsPosterExtension(path))- vpLoadLibrary("poster-probe", VP_POSTER_PROBE);// Loaded before the app gate too: the swizzle must be in place before// Settings builds its follow-up section.if (vpIsPreferences(path))diff --git a/VPhoneKit/VPhoneCoreKit/VirtualMachine/VPhoneGuestEnvironment.swift b/VPhoneKit/VPhoneCoreKit/VirtualMachine/VPhoneGuestEnvironment.swiftindex 49d6a516..94fc70cc 100644--- a/VPhoneKit/VPhoneCoreKit/VirtualMachine/VPhoneGuestEnvironment.swift+++ b/VPhoneKit/VPhoneCoreKit/VirtualMachine/VPhoneGuestEnvironment.swift@@ -21,7 +21,6 @@ public enum VPhoneGuestEnvironment {"libvphonefolddisplay.dylib","libvphonefoldguard.dylib","libvphonehinge.dylib",- "libvphoneposterprobe.dylib","libvphonegyro.dylib","libvphoneaccelerometer.dylib","libvphoneattitude.dylib",