Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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