Skip to content

Instantly share code, notes, and snippets.

@leptos-null
Created August 28, 2019 05:42
Show Gist options
  • Save leptos-null/0e120360f286f2c517430013d2feb701 to your computer and use it in GitHub Desktop.
Save leptos-null/0e120360f286f2c517430013d2feb701 to your computer and use it in GitHub Desktop.
[iOS] Open an application from the command line by bundle identifier
@import Foundation;
@import MobileCoreServices;
API_AVAILABLE(ios(5.0))
@interface LSApplicationWorkspace : NSObject
+ (instancetype)defaultWorkspace;
- (BOOL)openApplicationWithBundleID:(NSString *)bundleID API_AVAILABLE(ios(7.0));
@end
int main(int argc, char *argv[]) {
const char *firstArg = argv[1];
if (!firstArg) {
fprintf(stderr, "Usage: %s <bundleID>\n", argv[0]);
return 1;
}
NSString *bundleID = @(firstArg);
return [LSApplicationWorkspace.defaultWorkspace openApplicationWithBundleID:bundleID] ? EXIT_SUCCESS : EXIT_FAILURE;
}
@leptos-null
Copy link
Author

leptos-null commented Dec 26, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment