From 23b9278f15ea3b9584c895926141ad140a61760c Mon Sep 17 00:00:00 2001 From: ryanluoo Date: Mon, 25 Jan 2021 21:38:40 +0800 Subject: [PATCH] Add -k/--key option. Allow getting more properties of the app (#497) Add -k/--key option. Allow getting more properties of the app --- README.md | 5 +++++ src/ios-deploy/ios-deploy.m | 27 ++++++++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 66ec4d56..9666828c 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ python -m py_compile src/scripts/*.py && xcodebuild -target ios-deploy && xcodeb -E, --error_output write stderr to this file --detect_deadlocks start printing backtraces for all threads periodically after specific amount of seconds -f, --file_system specify file system for mkdir / list / upload / download / rm + -k, --key keys for the properties of the bundle. Joined by '&' and used only with -B and -j -F, --non-recursively specify non-recursively walk directory -j, --json format output as JSON @@ -151,6 +152,10 @@ The commands below assume that you have an app called `my.app` with bundle id `b // upload file to /DCIM ios-deploy -f -o/Users/ryan/Downloads/test.png -2/DCIM/test.png + + // get more properties of the bundle + ios-deploy -B -j --key=UIFileSharingEnabled&CFBundlePackageType + ## Demo diff --git a/src/ios-deploy/ios-deploy.m b/src/ios-deploy/ios-deploy.m index c3a89753..02b9cd70 100644 --- a/src/ios-deploy/ios-deploy.m +++ b/src/ios-deploy/ios-deploy.m @@ -98,6 +98,7 @@ char const*target_filename = NULL; char const*upload_pathname = NULL; char *bundle_id = NULL; +char *key = NULL; bool interactive = true; bool justlaunch = false; bool file_system = false; @@ -1706,13 +1707,16 @@ void get_battery_level(AMDeviceRef device) void list_bundle_id(AMDeviceRef device) { connect_and_start_session(device); - - NSArray *a = [NSArray arrayWithObjects: - @"CFBundleIdentifier", - @"CFBundleName", - @"CFBundleDisplayName", - @"CFBundleVersion", - @"CFBundleShortVersionString", nil]; + NSMutableArray *a = [NSMutableArray arrayWithObjects: + @"CFBundleIdentifier", + @"CFBundleName", + @"CFBundleDisplayName", + @"CFBundleVersion", + @"CFBundleShortVersionString", nil]; + if (key) { + NSArray * ns_keys = [[NSString stringWithUTF8String:key] componentsSeparatedByString:@"&"]; + [a addObjectsFromArray:ns_keys]; + } NSDictionary *optionsDict = [NSDictionary dictionaryWithObject:a forKey:@"ReturnAttributes"]; CFDictionaryRef options = (CFDictionaryRef)optionsDict; CFDictionaryRef result = nil; @@ -2279,6 +2283,7 @@ void usage(const char* app) { @" -f, --file_system specify file system for mkdir / list / upload / download / rm\n" @" -F, --non-recursively specify non-recursively walk directory\n" @" -j, --json format output as JSON\n" + @" -k, --key keys for the properties of the bundle. Joined by '&' and used only with -B and -j \n" @" --custom-script