Skip to content

Commit 23b9278

Browse files
authored
Add -k/--key option. Allow getting more properties of the app (#497)
Add -k/--key option. Allow getting more properties of the app
1 parent 00a39c8 commit 23b9278

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ python -m py_compile src/scripts/*.py && xcodebuild -target ios-deploy && xcodeb
8585
-E, --error_output <file> write stderr to this file
8686
--detect_deadlocks <sec> start printing backtraces for all threads periodically after specific amount of seconds
8787
-f, --file_system specify file system for mkdir / list / upload / download / rm
88+
-k, --key keys for the properties of the bundle. Joined by '&' and used only with -B <list_bundle_id> and -j <json>
8889
-F, --non-recursively specify non-recursively walk directory
8990
-j, --json format output as JSON
9091

@@ -151,6 +152,10 @@ The commands below assume that you have an app called `my.app` with bundle id `b
151152

152153
// upload file to /DCIM
153154
ios-deploy -f -o/Users/ryan/Downloads/test.png -2/DCIM/test.png
155+
156+
// get more properties of the bundle
157+
ios-deploy -B -j --key=UIFileSharingEnabled&CFBundlePackageType
158+
154159

155160
## Demo
156161

src/ios-deploy/ios-deploy.m

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
char const*target_filename = NULL;
9999
char const*upload_pathname = NULL;
100100
char *bundle_id = NULL;
101+
char *key = NULL;
101102
bool interactive = true;
102103
bool justlaunch = false;
103104
bool file_system = false;
@@ -1706,13 +1707,16 @@ void get_battery_level(AMDeviceRef device)
17061707
void list_bundle_id(AMDeviceRef device)
17071708
{
17081709
connect_and_start_session(device);
1709-
1710-
NSArray *a = [NSArray arrayWithObjects:
1711-
@"CFBundleIdentifier",
1712-
@"CFBundleName",
1713-
@"CFBundleDisplayName",
1714-
@"CFBundleVersion",
1715-
@"CFBundleShortVersionString", nil];
1710+
NSMutableArray *a = [NSMutableArray arrayWithObjects:
1711+
@"CFBundleIdentifier",
1712+
@"CFBundleName",
1713+
@"CFBundleDisplayName",
1714+
@"CFBundleVersion",
1715+
@"CFBundleShortVersionString", nil];
1716+
if (key) {
1717+
NSArray * ns_keys = [[NSString stringWithUTF8String:key] componentsSeparatedByString:@"&"];
1718+
[a addObjectsFromArray:ns_keys];
1719+
}
17161720
NSDictionary *optionsDict = [NSDictionary dictionaryWithObject:a forKey:@"ReturnAttributes"];
17171721
CFDictionaryRef options = (CFDictionaryRef)optionsDict;
17181722
CFDictionaryRef result = nil;
@@ -2279,6 +2283,7 @@ void usage(const char* app) {
22792283
@" -f, --file_system specify file system for mkdir / list / upload / download / rm\n"
22802284
@" -F, --non-recursively specify non-recursively walk directory\n"
22812285
@" -j, --json format output as JSON\n"
2286+
@" -k, --key keys for the properties of the bundle. Joined by '&' and used only with -B <list_bundle_id> and -j <json> \n"
22822287
@" --custom-script <script> path to custom python script to execute in lldb\n"
22832288
@" --custom-command <command> specify additional lldb commands to execute\n",
22842289
[NSString stringWithUTF8String:app]);
@@ -2336,13 +2341,14 @@ int main(int argc, char *argv[]) {
23362341
{ "app_deltas", required_argument, NULL, 'A'},
23372342
{ "file_system", no_argument, NULL, 'f'},
23382343
{ "non-recursively", no_argument, NULL, 'F'},
2344+
{ "key", optional_argument, NULL, 'k' },
23392345
{ "custom-script", required_argument, NULL, 1001},
23402346
{ "custom-command", required_argument, NULL, 1002},
23412347
{ NULL, 0, NULL, 0 },
23422348
};
23432349
int ch;
23442350

2345-
while ((ch = getopt_long(argc, argv, "VmcdvunrILefFD:R:X:i:b:a:t:p:1:2:o:l:w:9BWjNs:OE:CA:", longopts, NULL)) != -1)
2351+
while ((ch = getopt_long(argc, argv, "VmcdvunrILefFD:R:X:i:b:a:t:p:1:2:o:l:w:9BWjNs:OE:CA:k:", longopts, NULL)) != -1)
23462352
{
23472353
switch (ch) {
23482354
case 'm':
@@ -2488,6 +2494,9 @@ int main(int argc, char *argv[]) {
24882494
}
24892495
[custom_commands appendFormat:@"%s\n", optarg];
24902496
break;
2497+
case 'k':
2498+
key = optarg;
2499+
break;
24912500
default:
24922501
usage(argv[0]);
24932502
return exitcode_error;
@@ -2501,7 +2510,7 @@ int main(int argc, char *argv[]) {
25012510

25022511
if (!app_path && !detect_only && !command_only) {
25032512
usage(argv[0]);
2504-
on_error(@"One of -[b|c|o|l|w|D|R|e|9] is required to proceed!");
2513+
on_error(@"One of -[b|c|o|l|w|D|R|X|e|B|C|9] is required to proceed!");
25052514
}
25062515

25072516
if (unbuffered) {

0 commit comments

Comments
 (0)