Skip to content

Commit e5fc979

Browse files
IncontIncont
authored andcommitted
added options --list_bundle_id
1 parent 18873b8 commit e5fc979

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

ios-deploy.c

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,6 +1323,33 @@ int app_exists(AMDeviceRef device)
13231323
return -1;
13241324
}
13251325

1326+
void list_bundle_id(AMDeviceRef device)
1327+
{
1328+
AMDeviceConnect(device);
1329+
assert(AMDeviceIsPaired(device));
1330+
check_error(AMDeviceValidatePairing(device));
1331+
check_error(AMDeviceStartSession(device));
1332+
1333+
NSArray *a = [NSArray arrayWithObjects:@"CFBundleIdentifier", nil];
1334+
NSDictionary *optionsDict = [NSDictionary dictionaryWithObject:a forKey:@"ReturnAttributes"];
1335+
CFDictionaryRef options = (CFDictionaryRef)optionsDict;
1336+
CFDictionaryRef result = nil;
1337+
check_error(AMDeviceLookupApplications(device, options, &result));
1338+
1339+
CFIndex count;
1340+
count = CFDictionaryGetCount(result);
1341+
const void *keys[count];
1342+
CFDictionaryGetKeysAndValues(result, keys, NULL);
1343+
for(int i = 0; i < count; ++i) {
1344+
CFStringRef test = (CFStringRef)keys[i];
1345+
const char * key = CFStringGetCStringPtr((CFStringRef)keys[i], kCFStringEncodingASCII);
1346+
printf("%s\n", key);
1347+
}
1348+
1349+
check_error(AMDeviceStopSession(device));
1350+
check_error(AMDeviceDisconnect(device));
1351+
}
1352+
13261353
void copy_file_callback(afc_connection* afc_conn_p, const char *name,int file)
13271354
{
13281355
const char *local_name=name;
@@ -1574,6 +1601,8 @@ void handle_device(AMDeviceRef device) {
15741601
exit(app_exists(device));
15751602
} else if (strcmp("uninstall_only", command) == 0) {
15761603
uninstall_app(device);
1604+
} else if (strcmp("list_bundle_id", command) == 0) {
1605+
list_bundle_id(device);
15771606
}
15781607
exit(0);
15791608
}
@@ -1756,7 +1785,8 @@ void usage(const char* app) {
17561785
" -D, --mkdir <dir> make directory on device\n"
17571786
" -R, --rm <path> remove file or directory on device (directories must be empty)\n"
17581787
" -V, --version print the executable version \n"
1759-
" -e, --exists check if the app with given bundle_id is installed or not \n",
1788+
" -e, --exists check if the app with given bundle_id is installed or not \n"
1789+
" -B, --list_bundle_id list bundle_id \n",
17601790
app);
17611791
}
17621792

@@ -1790,11 +1820,12 @@ int main(int argc, char *argv[]) {
17901820
{ "mkdir", required_argument, NULL, 'D'},
17911821
{ "rm", required_argument, NULL, 'R'},
17921822
{ "exists", no_argument, NULL, 'e'},
1823+
{ "list_bundle_id", no_argument, NULL, 'B'},
17931824
{ NULL, 0, NULL, 0 },
17941825
};
17951826
char ch;
17961827

1797-
while ((ch = getopt_long(argc, argv, "VmcdvunrILeD:R:i:b:a:t:g:x:p:1:2:o:l::w::9::", longopts, NULL)) != -1)
1828+
while ((ch = getopt_long(argc, argv, "VmcdvunrILeD:R:i:b:a:t:g:x:p:1:2:o:l::w::9::B::", longopts, NULL)) != -1)
17981829
{
17991830
switch (ch) {
18001831
case 'm':
@@ -1884,6 +1915,10 @@ int main(int argc, char *argv[]) {
18841915
command_only = true;
18851916
command = "exists";
18861917
break;
1918+
case 'B':
1919+
command_only = true;
1920+
command = "list_bundle_id";
1921+
break;
18871922
default:
18881923
usage(argv[0]);
18891924
return exitcode_error;

0 commit comments

Comments
 (0)