Skip to content

Instantly share code, notes, and snippets.

@udevsharold
Created July 29, 2021 15:18
Show Gist options
  • Select an option

  • Save udevsharold/af06002c6d8d28df8557ab747a3125e5 to your computer and use it in GitHub Desktop.

Select an option

Save udevsharold/af06002c6d8d28df8557ab747a3125e5 to your computer and use it in GitHub Desktop.
Launch and kill WatchKit app (Apple Watch) from iOS
// Discovered by RE WatchKit.Framework - udevs
//
// To use this, calling process must holds "com.apple.companionappd.connect.allow" entitlement
extern CFStringRef SPLaunchGizmoAppMode;
extern CFStringRef SPLaunchGizmoAppModeApp;
extern CFStringRef SPXcodeSupportAppLaunchModeKey;
extern CFStringRef SPXcodeSupportAppLaunchModeValueGlance;
extern CFStringRef SPXcodeSupportAppLaunchModeValueComplication;
extern CFStringRef SPXcodeSupportAppLaunchModeValueNotification;
extern "C" void SPLaunchSockPuppetAppForCompanionAppWithIdentifier(NSString *identifier, NSDictionary *options, void (^completion)(BOOL success, NSError *error));
extern "C" void SPTerminateSockPuppetAppForCompanionAppWithIdentifier(NSString *identifier, void (^completion)(NSError *error));
NSString *bundleID = @"com.spotify.client";
NSDictionary *options = @{[(__bridge NSString *)SPLaunchGizmoAppMode] : (__bridge NSString *)SPLaunchGizmoAppModeApp};
//NSDictionary *options = @{[(__bridge NSString *)SPXcodeSupportAppLaunchModeKey] : (__bridge NSString *)SPXcodeSupportAppLaunchModeValueComplication};
void *handle = dlopen("/System/Library/Frameworks/WatchKit.framework/WatchKit", RTLD_LAZY);
if (handle){
//Launch app
SPLaunchSockPuppetAppForCompanionAppWithIdentifier(bundleID, options, ^(BOOL success, NSError *error){
if (error) NSLog(@"%@", error.localizedDescription);
});
//Kill app
SPTerminateSockPuppetAppForCompanionAppWithIdentifier(bundleID, ^(NSError *error){
if (error) NSLog(@"%@", error.localizedDescription);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment