Created
August 28, 2019 05:42
-
-
Save leptos-null/0e120360f286f2c517430013d2feb701 to your computer and use it in GitHub Desktop.
[iOS] Open an application from the command line by bundle identifier
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Similar projects:
https://github.com/conradev/Open
https://github.com/ClarkeCDC/open11 (similar code)
sblaunch.c
in https://github.com/bored-engineer/iOS-sbutils