From d51bb22f23f2d78ca5116d48e0726ea3ee9fed07 Mon Sep 17 00:00:00 2001 From: CSOscarTanner Date: Tue, 21 Oct 2014 14:33:33 -0200 Subject: [PATCH 01/10] Fixed problem with the parser of the value of the parameter -i. --- ios-deploy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios-deploy.c b/ios-deploy.c index 1189753..cbd4342 100644 --- a/ios-deploy.c +++ b/ios-deploy.c @@ -1510,7 +1510,7 @@ int main(int argc, char *argv[]) { }; char ch; - while ((ch = getopt_long(argc, argv, "VmcdvunrILib:a:t:g:x:p:1:2:o:l::w::", longopts, NULL)) != -1) + while ((ch = getopt_long(argc, argv, "VmcdvunrILi:b:a:t:g:x:p:1:2:o:l::w::", longopts, NULL)) != -1) { switch (ch) { case 'm': From 6f662ae450ed85784643ac1f1d31e114cde949ef Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Thu, 13 Nov 2014 17:33:44 -0800 Subject: [PATCH 02/10] Fixes phonegap/ios-deploy#37 - AMDeviceValidatePairing fails when uninstalling --- ios-deploy.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ios-deploy.c b/ios-deploy.c index 4540c03..e78d674 100644 --- a/ios-deploy.c +++ b/ios-deploy.c @@ -1490,13 +1490,15 @@ void handle_device(AMDeviceRef device) { assert(AMDeviceIsPaired(device)); assert(AMDeviceValidatePairing(device) == 0); assert(AMDeviceStartSession(device) == 0); - - assert(AMDeviceSecureUninstallApplication(0, device, bundle_id, 0, NULL, 0) == 0); - + + int code = AMDeviceSecureUninstallApplication(0, device, bundle_id, 0, NULL, 0); + if (code == 0) { + printf("[ OK ] Uninstalled package with bundle id %s\n", CFStringGetCStringPtr(bundle_id, CFStringGetSystemEncoding())); + } else { + printf("[ ERROR ] Could not uninstall package with bundle id %s\n", CFStringGetCStringPtr(bundle_id, CFStringGetSystemEncoding())); + } assert(AMDeviceStopSession(device) == 0); assert(AMDeviceDisconnect(device) == 0); - - printf("[ OK ] Uninstalled package with bundle id %s\n", CFStringGetCStringPtr(bundle_id, CFStringGetSystemEncoding())); } } From 707565701559d301b9336c45b555dcb481089f21 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Thu, 13 Nov 2014 22:57:58 -0800 Subject: [PATCH 03/10] Fixes phonegap/ios-deploy#74 - SIGSEGV-ed while listing the sandbox of an application on iOS8 --- ios-deploy.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ios-deploy.c b/ios-deploy.c index e78d674..342fb15 100644 --- a/ios-deploy.c +++ b/ios-deploy.c @@ -1163,7 +1163,12 @@ void read_dir(service_conn_t afcFd, afc_connection* afc_conn_p, const char* dir, char *key, *val; int not_dir = 0; - AFCFileInfoOpen(afc_conn_p, dir, &afc_dict_p); + unsigned int code = AFCFileInfoOpen(afc_conn_p, dir, &afc_dict_p); + if (code != 0) { + // there was a problem reading or opening the file to get info on it, abort + return; + } + while((AFCKeyValueRead(afc_dict_p,&key,&val) == 0) && key && val) { if (strcmp(key,"st_ifmt")==0) { not_dir = strcmp(val,"S_IFDIR"); From 5bfc25376a0e0dac22cd0640434d7c52615cdb2b Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Thu, 13 Nov 2014 22:58:18 -0800 Subject: [PATCH 04/10] Update package.json version to 1.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6eb080f..7db68e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ios-deploy", - "version": "1.2.0", + "version": "1.3.0", "description": "launch iOS apps iOS devices from the command line (Xcode 6)", "main": "ios-deploy", "scripts": { From 63303ea4b0004379288c80a288f824d84ec45362 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Thu, 13 Nov 2014 23:24:27 -0800 Subject: [PATCH 05/10] Removed unused gdbargs and gdbexec options. --- README.md | 43 ++++++++++++++++++++++--------------------- ios-deploy.c | 3 --- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index bd44b49..f936c64 100644 --- a/README.md +++ b/README.md @@ -11,27 +11,28 @@ Install and debug iPhone apps without using Xcode. Designed to work on unjailbro ## Usage Usage: ./ios-deploy [OPTION]... - -d, --debug launch the app in GDB after installation - -i, --id the id of the device to connect to - -c, --detect only detect if the device is connected - -b, --bundle the path to the app bundle to be installed - -a, --args command line arguments to pass to the app when launching it - -t, --timeout number of seconds to wait for a device to be connected - -u, --unbuffered don't buffer stdout - -g, --gdbargs extra arguments to pass to GDB when starting the debugger - -x, --gdbexec GDB commands script file - -n, --nostart do not start the app when debugging - -I, --noninteractive start in non interactive mode (quit when app crashes or exits) - -L, --justlaunch just launch the app and exit lldb - -v, --verbose enable verbose output - -m, --noinstall directly start debugging without app install (-d not required) - -p, --port port used for device, default: 12345 - -r, --uninstall uninstall the app before install (do not use with -m; app cache and data are cleared) - -1, --bundle_id specify bundle id for list and upload - -l, --list list files - -o, --upload upload file - -2, --to use together with upload file. specify target for upload - -V, --version print the executable version + -d, --debug launch the app in GDB after installation\n" + -i, --id the id of the device to connect to\n" + -c, --detect only detect if the device is connected\n" + -b, --bundle the path to the app bundle to be installed\n" + -a, --args command line arguments to pass to the app when launching it\n" + -t, --timeout number of seconds to wait for a device to be connected\n" + -u, --unbuffered don't buffer stdout\n" + -g, --gdbargs extra arguments to pass to GDB when starting the debugger\n" + -x, --gdbexec GDB commands script file\n" + -n, --nostart do not start the app when debugging\n" + -I, --noninteractive start in non interactive mode (quit when app crashes or exits)\n" + -L, --justlaunch just launch the app and exit lldb\n" + -v, --verbose enable verbose output\n" + -m, --noinstall directly start debugging without app install (-d not required)\n" + -p, --port port used for device, default: 12345 \n" + -r, --uninstall uninstall the app before install (do not use with -m; app cache and data are cleared) \n" + -1, --bundle_id specify bundle id for list and upload\n" + -l, --list list files\n" + -o, --upload upload file\n" + -w, --download download app tree\n" + -2, --to use together with up/download file/tree. specify target\n" + -V, --version print the executable version \n", ## Demo diff --git a/ios-deploy.c b/ios-deploy.c index 342fb15..c8d22cb 100644 --- a/ios-deploy.c +++ b/ios-deploy.c @@ -1635,8 +1635,6 @@ void usage(const char* app) { " -a, --args command line arguments to pass to the app when launching it\n" " -t, --timeout number of seconds to wait for a device to be connected\n" " -u, --unbuffered don't buffer stdout\n" - " -g, --gdbargs extra arguments to pass to GDB when starting the debugger\n" - " -x, --gdbexec GDB commands script file\n" " -n, --nostart do not start the app when debugging\n" " -I, --noninteractive start in non interactive mode (quit when app crashes or exits)\n" " -L, --justlaunch just launch the app and exit lldb\n" @@ -1665,7 +1663,6 @@ int main(int argc, char *argv[]) { { "args", required_argument, NULL, 'a' }, { "verbose", no_argument, NULL, 'v' }, { "timeout", required_argument, NULL, 't' }, - { "gdbexec", no_argument, NULL, 'x' }, { "unbuffered", no_argument, NULL, 'u' }, { "nostart", no_argument, NULL, 'n' }, { "noninteractive", no_argument, NULL, 'I' }, From 021c222a552fcb110e18adc966bfad8979b44294 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Thu, 13 Nov 2014 23:24:51 -0800 Subject: [PATCH 06/10] Update README. Removed gdbargs, gdbexec. Added download. --- README.md | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index f936c64..0d50d32 100644 --- a/README.md +++ b/README.md @@ -10,29 +10,27 @@ Install and debug iPhone apps without using Xcode. Designed to work on unjailbro ## Usage - Usage: ./ios-deploy [OPTION]... - -d, --debug launch the app in GDB after installation\n" - -i, --id the id of the device to connect to\n" - -c, --detect only detect if the device is connected\n" - -b, --bundle the path to the app bundle to be installed\n" - -a, --args command line arguments to pass to the app when launching it\n" - -t, --timeout number of seconds to wait for a device to be connected\n" - -u, --unbuffered don't buffer stdout\n" - -g, --gdbargs extra arguments to pass to GDB when starting the debugger\n" - -x, --gdbexec GDB commands script file\n" - -n, --nostart do not start the app when debugging\n" - -I, --noninteractive start in non interactive mode (quit when app crashes or exits)\n" - -L, --justlaunch just launch the app and exit lldb\n" - -v, --verbose enable verbose output\n" - -m, --noinstall directly start debugging without app install (-d not required)\n" - -p, --port port used for device, default: 12345 \n" - -r, --uninstall uninstall the app before install (do not use with -m; app cache and data are cleared) \n" - -1, --bundle_id specify bundle id for list and upload\n" - -l, --list list files\n" - -o, --upload upload file\n" - -w, --download download app tree\n" - -2, --to use together with up/download file/tree. specify target\n" - -V, --version print the executable version \n", + Usage: ios-deploy [OPTION]... + -d, --debug launch the app in GDB after installation + -i, --id the id of the device to connect to + -c, --detect only detect if the device is connected + -b, --bundle the path to the app bundle to be installed + -a, --args command line arguments to pass to the app when launching it + -t, --timeout number of seconds to wait for a device to be connected + -u, --unbuffered don't buffer stdout + -n, --nostart do not start the app when debugging + -I, --noninteractive start in non interactive mode (quit when app crashes or exits) + -L, --justlaunch just launch the app and exit lldb + -v, --verbose enable verbose output + -m, --noinstall directly start debugging without app install (-d not required) + -p, --port port used for device, default: 12345 + -r, --uninstall uninstall the app before install (do not use with -m; app cache and data are cleared) + -1, --bundle_id specify bundle id for list and upload + -l, --list list files + -o, --upload upload file + -w, --download download app tree + -2, --to use together with up/download file/tree. specify target + -V, --version print the executable version ## Demo From 7a447b480f4476c3ee383b031b9f0ef73826ba66 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Thu, 13 Nov 2014 23:47:50 -0800 Subject: [PATCH 07/10] Fixes phonegap/ios-deploy#79 - Update README.md for sample usage of ios-deploy flags and options --- README.md | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0d50d32..2472d9f 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ ios-deploy ========== -Install and debug iPhone apps without using Xcode. Designed to work on unjailbroken devices. +Install and debug iOS apps without using Xcode. Designed to work on un-jailbroken devices. ## Requirements -* Mac OS X. Tested on Snow Leopard only. -* You need to have a valid iPhone development certificate installed. -* Xcode must be installed, along with the SDK for your iOS version. +* Mac OS X. Tested on 10.10 Yosemite and iOS 8.1 +* You need to have a valid iOS development certificate installed. +* Xcode 6.1 should be installed ## Usage @@ -31,7 +31,32 @@ Install and debug iPhone apps without using Xcode. Designed to work on unjailbro -w, --download download app tree -2, --to use together with up/download file/tree. specify target -V, --version print the executable version - + +## Examples + +The commands below assume that you have an app called `my.app` with bundle id `bundle.id`. Substitute where necessary. + + // deploy and debug your app to a connected device + ios-deploy --debug --bundle my.app + + // deploy and launch your app to a connected device, but quit the debugger after + ios-deploy --justlaunch --debug --bundle my.app + + // deploy and launch your app to a connected device, quit when app crashes or exits + ios-deploy --noninteractive --debug --bundle my.app + + // Upload a file to your app's Documents folder + ios-deploy --bundle_id 'bundle.id' --upload test.txt --to Documents/test.txt + + // Download your app's Documents, Library and tmp folders + ios-deploy --bundle_id 'bundle.id' --download --to MyDestinationFolder + + // List the contents of your app's Documents, Library and tmp folders + ios-deploy --bundle_id 'bundle.id' --list + + // deploy and debug your app to a connected device, uninstall the app first + ios-deploy --uninstall --debug --bundle my.app + ## Demo * The included demo.app represents the minimum required to get code running on iOS. @@ -40,7 +65,7 @@ Install and debug iPhone apps without using Xcode. Designed to work on unjailbro ## Notes -* With some modifications, it may be possible to use this without Xcode installed; however, you would need a copy of the relevant DeveloperDiskImage.dmg (included with Xcode). GDB would also run slower as symbols would be downloaded from the device on-the-fly. +* With some modifications, it may be possible to use this without Xcode installed; however, you would need a copy of the relevant DeveloperDiskImage.dmg (included with Xcode). lldb would also run slower as symbols would be downloaded from the device on-the-fly. ## Listing Device Ids From 767c386ba9e966cb8fb68879b30b55c0ae23fa8c Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Fri, 14 Nov 2014 13:07:19 -0800 Subject: [PATCH 08/10] Fixes phonegap/ios-deploy#80 --detect not showing non-zero exit code when no devices are detected. --- ios-deploy.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ios-deploy.c b/ios-deploy.c index c8d22cb..36a3eeb 100644 --- a/ios-deploy.c +++ b/ios-deploy.c @@ -1607,8 +1607,10 @@ void timeout_callback(CFRunLoopTimerRef timer, void *info) { } else { - if (!debug) + if (!debug) { printf("[....] No more devices found.\n"); + exit(exitcode_error); + } else { int mypid = getpid(); From 7c9af71d86098c41322176cc7aa4662bc8eeaaf3 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Fri, 14 Nov 2014 13:09:11 -0800 Subject: [PATCH 09/10] Updated version to 1.3.1 --- ios-deploy.c | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ios-deploy.c b/ios-deploy.c index 36a3eeb..6fc20f5 100644 --- a/ios-deploy.c +++ b/ios-deploy.c @@ -16,7 +16,7 @@ #include #include "MobileDevice.h" -#define APP_VERSION "1.3.0" +#define APP_VERSION "1.3.1" #define PREP_CMDS_PATH "/tmp/fruitstrap-lldb-prep-cmds-" #define LLDB_SHELL "lldb -s " PREP_CMDS_PATH /* diff --git a/package.json b/package.json index 7db68e3..d872fef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ios-deploy", - "version": "1.3.0", + "version": "1.3.1", "description": "launch iOS apps iOS devices from the command line (Xcode 6)", "main": "ios-deploy", "scripts": { From 33f6a83e1d94df5cf5041e9e16394409c4f63656 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Sun, 16 Nov 2014 20:49:33 -0800 Subject: [PATCH 10/10] Fixes phonegap/ios-deploy#80 (re-fix) --detect not showing non-zero exit code when no devices are detected. When --detect is turned on, --debug is turned on implicitly so you won't get a segmentation fault. --- ios-deploy.c | 14 +++++++++----- package.json | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ios-deploy.c b/ios-deploy.c index 6fc20f5..156d1bf 100644 --- a/ios-deploy.c +++ b/ios-deploy.c @@ -16,7 +16,7 @@ #include #include "MobileDevice.h" -#define APP_VERSION "1.3.1" +#define APP_VERSION "1.3.2" #define PREP_CMDS_PATH "/tmp/fruitstrap-lldb-prep-cmds-" #define LLDB_SHELL "lldb -s " PREP_CMDS_PATH /* @@ -1448,6 +1448,7 @@ void handle_device(AMDeviceRef device) { if (detect_only) { printf("[....] Found %s connected through %s.\n", CFStringGetCStringPtr(device_full_name, CFStringGetSystemEncoding()), CFStringGetCStringPtr(device_interface_name, CFStringGetSystemEncoding())); + found_device = true; return; } if (device_id != NULL) { @@ -1609,10 +1610,12 @@ void timeout_callback(CFRunLoopTimerRef timer, void *info) { { if (!debug) { printf("[....] No more devices found.\n"); - exit(exitcode_error); } - else - { + + if (detect_only && !found_device) { + exit(exitcode_error); + return; + } else { int mypid = getpid(); if ((parent != 0) && (parent == mypid) && (child != 0)) { @@ -1630,7 +1633,7 @@ void timeout_callback(CFRunLoopTimerRef timer, void *info) { void usage(const char* app) { printf( "Usage: %s [OPTION]...\n" - " -d, --debug launch the app in GDB after installation\n" + " -d, --debug launch the app in lldb after installation\n" " -i, --id the id of the device to connect to\n" " -c, --detect only detect if the device is connected\n" " -b, --bundle the path to the app bundle to be installed\n" @@ -1723,6 +1726,7 @@ int main(int argc, char *argv[]) { break; case 'c': detect_only = true; + debug = 1; break; case 'V': show_version(); diff --git a/package.json b/package.json index d872fef..53b15d9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ios-deploy", - "version": "1.3.1", + "version": "1.3.2", "description": "launch iOS apps iOS devices from the command line (Xcode 6)", "main": "ios-deploy", "scripts": {