Skip to content

Commit

Permalink
Add -k/--key option. Allow getting more properties of the app (#497)
Browse files Browse the repository at this point in the history
Add -k/--key option. Allow getting more properties of the app
  • Loading branch information
ryanluoo authored Jan 25, 2021
1 parent 00a39c8 commit 23b9278
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ python -m py_compile src/scripts/*.py && xcodebuild -target ios-deploy && xcodeb
-E, --error_output <file> write stderr to this file
--detect_deadlocks <sec> 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 <list_bundle_id> and -j <json>
-F, --non-recursively specify non-recursively walk directory
-j, --json format output as JSON

Expand Down Expand Up @@ -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

Expand Down
27 changes: 18 additions & 9 deletions src/ios-deploy/ios-deploy.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 <list_bundle_id> and -j <json> \n"
@" --custom-script <script> path to custom python script to execute in lldb\n"
@" --custom-command <command> specify additional lldb commands to execute\n",
[NSString stringWithUTF8String:app]);
Expand Down Expand Up @@ -2336,13 +2341,14 @@ int main(int argc, char *argv[]) {
{ "app_deltas", required_argument, NULL, 'A'},
{ "file_system", no_argument, NULL, 'f'},
{ "non-recursively", no_argument, NULL, 'F'},
{ "key", optional_argument, NULL, 'k' },
{ "custom-script", required_argument, NULL, 1001},
{ "custom-command", required_argument, NULL, 1002},
{ NULL, 0, NULL, 0 },
};
int ch;

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)
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)
{
switch (ch) {
case 'm':
Expand Down Expand Up @@ -2488,6 +2494,9 @@ int main(int argc, char *argv[]) {
}
[custom_commands appendFormat:@"%s\n", optarg];
break;
case 'k':
key = optarg;
break;
default:
usage(argv[0]);
return exitcode_error;
Expand All @@ -2501,7 +2510,7 @@ int main(int argc, char *argv[]) {

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

if (unbuffered) {
Expand Down

0 comments on commit 23b9278

Please sign in to comment.