Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d61b7ca7c | ||
|
|
590da67714 | ||
|
|
8749a57936 | ||
|
|
3ba7403a39 | ||
|
|
84aeaad03b | ||
|
|
ddcb4932ab | ||
|
|
11f1a89128 | ||
|
|
c97b972172 | ||
|
|
1cb6110985 | ||
|
|
3dadb53b3b | ||
|
|
39aa232f97 | ||
|
|
609b635870 | ||
|
|
522f7bd667 | ||
|
|
250794ce98 | ||
|
|
41eeedc472 | ||
|
|
cdbe112ec6 | ||
|
|
5377d9bec7 | ||
|
|
e5fc979998 | ||
|
|
18873b8340 | ||
|
|
a750efa382 | ||
|
|
0940a4d079 | ||
|
|
b72d31b816 | ||
|
|
5690b10635 | ||
|
|
d90171d8e7 | ||
|
|
02c23792ee | ||
|
|
3e8a897fbc | ||
|
|
ba60ff6351 | ||
|
|
134a0a5fd0 | ||
|
|
96e91eb269 | ||
|
|
8577ef3411 | ||
|
|
99f401018d | ||
|
|
6ac084844e | ||
|
|
3dcd64f7c0 | ||
|
|
12334f8ddf |
15
README.md
15
README.md
@@ -8,7 +8,17 @@ Install and debug iOS apps without using Xcode. Designed to work on un-jailbroke
|
||||
* You need to have a valid iOS Development certificate installed.
|
||||
* Xcode 6 or greater should be installed
|
||||
|
||||
## Roadmap
|
||||
|
||||
See our [milestones](https://github.com/phonegap/ios-deploy/milestones).
|
||||
|
||||
Significant changes:
|
||||
|
||||
1.8.0 will use an Xcode project instead of a Makefile (to prepare for 2.0.0)
|
||||
2.0.0 will break out the commands into their own files, and create ios-deploy-lib for node.js use
|
||||
|
||||
## Installation
|
||||
=======
|
||||
|
||||
ios-deploy installation is made simple using the node.js package manager. If you use [Homebrew](http://brew.sh/), install [node.js](https://nodejs.org):
|
||||
|
||||
@@ -57,7 +67,7 @@ This will install ios-deploy in the `bin` folder of `/usr/local`, i.e. `/usr/loc
|
||||
-R, --rm <path> remove file or directory on device (directories must be empty)
|
||||
-V, --version print the executable version
|
||||
-e, --exists check if the app with given bundle_id is installed or not
|
||||
|
||||
-B, --list_bundle_id list bundle_id
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -95,6 +105,9 @@ The commands below assume that you have an app called `my.app` with bundle id `b
|
||||
|
||||
// Uninstall an app
|
||||
ios-deploy --uninstall_only --bundle_id my.bundle.id
|
||||
|
||||
// list all bundle ids of all apps on your device
|
||||
ios-deploy --list_bundle_id
|
||||
|
||||
## Demo
|
||||
|
||||
|
||||
300
ios-deploy.c
300
ios-deploy.c
@@ -18,7 +18,7 @@
|
||||
#include "MobileDevice.h"
|
||||
#include "errors.h"
|
||||
|
||||
#define APP_VERSION "1.6.3"
|
||||
#define APP_VERSION @"1.7.0"
|
||||
#define PREP_CMDS_PATH "/tmp/fruitstrap-lldb-prep-cmds-"
|
||||
#define LLDB_SHELL "lldb -s " PREP_CMDS_PATH
|
||||
/*
|
||||
@@ -192,33 +192,42 @@ const int exitcode_app_crash = 254;
|
||||
if (err != 0) \
|
||||
{ \
|
||||
const char* msg = get_error_message(err); \
|
||||
on_error("Error 0x%x: %s " #call, err, msg ? msg : "unknown."); \
|
||||
/*on_error("Error 0x%x: %s " #call, err, msg ? msg : "unknown.");*/ \
|
||||
on_error(@"Error 0x%x: %s " #call, err, msg ? [NSString stringWithUTF8String:msg] : @"unknown."); \
|
||||
} \
|
||||
} while (false);
|
||||
|
||||
// Print error message and exit
|
||||
void on_error(const char* fmt, ...) {
|
||||
char buf[256];
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
fprintf(stderr, "[ !! ] ");
|
||||
vfprintf(stderr, fmt, args);
|
||||
fprintf(stderr, "\n");
|
||||
va_end(args);
|
||||
void on_error(NSString* format, ...)
|
||||
{
|
||||
va_list valist;
|
||||
va_start(valist, format);
|
||||
NSString* str = [[[NSString alloc] initWithFormat:format arguments:valist] autorelease];
|
||||
va_end(valist);
|
||||
|
||||
NSLog(@"[ !! ] %@", str);
|
||||
|
||||
exit(exitcode_error);
|
||||
}
|
||||
|
||||
// Print error message getting last errno and exit
|
||||
void on_sys_error(const char* fmt, ...) {
|
||||
void on_sys_error(NSString* format, ...) {
|
||||
const char* errstr = strerror(errno);
|
||||
|
||||
char buf[256];
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buf, 256, fmt, args);
|
||||
on_error("%s: %s", buf, errstr);
|
||||
va_end(args);
|
||||
va_list valist;
|
||||
va_start(valist, format);
|
||||
NSString* str = [[[NSString alloc] initWithFormat:format arguments:valist] autorelease];
|
||||
va_end(valist);
|
||||
|
||||
on_error(@"%@ : %@", str, errstr);
|
||||
}
|
||||
|
||||
void NSLogOut(NSString* format, ...) {
|
||||
va_list valist;
|
||||
va_start(valist, format);
|
||||
NSString* str = [[[NSString alloc] initWithFormat:format arguments:valist] autorelease];
|
||||
va_end(valist);
|
||||
|
||||
[[str stringByAppendingString:@"\n"] writeToFile:@"/dev/stdout" atomically:NO encoding:NSUTF8StringEncoding error:nil];
|
||||
}
|
||||
|
||||
Boolean path_exists(CFTypeRef path) {
|
||||
@@ -260,7 +269,7 @@ CFStringRef find_path(CFStringRef rootPath, CFStringRef namePattern, CFStringRef
|
||||
CFRelease(cf_command);
|
||||
|
||||
if (!(fpipe = (FILE *)popen(command, "r")))
|
||||
on_sys_error("Error encountered while opening pipe");
|
||||
on_sys_error(@"Error encountered while opening pipe");
|
||||
|
||||
char buffer[256] = { '\0' };
|
||||
|
||||
@@ -282,7 +291,7 @@ CFStringRef copy_xcode_dev_path() {
|
||||
char *command = "xcode-select -print-path";
|
||||
|
||||
if (!(fpipe = (FILE *)popen(command, "r")))
|
||||
on_sys_error("Error encountered while opening pipe");
|
||||
on_sys_error(@"Error encountered while opening pipe");
|
||||
|
||||
char buffer[256] = { '\0' };
|
||||
|
||||
@@ -445,13 +454,8 @@ CFStringRef get_device_full_name(const AMDeviceRef device) {
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
char *devName = MYCFStringCopyUTF8String(device_name);
|
||||
CFShow([NSString stringWithFormat:@"Device Name: %s\n", devName]);
|
||||
free(devName);
|
||||
|
||||
char *mdlName = MYCFStringCopyUTF8String(model_name);
|
||||
CFShow([NSString stringWithFormat:@"Model Name: %s\n", mdlName]);
|
||||
free(mdlName);
|
||||
NSLogOut(@"Device Name: %@", device_name);
|
||||
NSLogOut(@"Model Name: %@", model_name);
|
||||
}
|
||||
|
||||
if(device_name != NULL && model_name != NULL)
|
||||
@@ -530,7 +534,7 @@ CFStringRef copy_device_support_path(AMDeviceRef device) {
|
||||
CFRelease(build);
|
||||
|
||||
if (path == NULL)
|
||||
on_error("Unable to locate DeviceSupport directory. This probably means you don't have Xcode installed, you will need to launch the app manually and logging output will not be shown!");
|
||||
on_error(@"Unable to locate DeviceSupport directory. This probably means you don't have Xcode installed, you will need to launch the app manually and logging output will not be shown!");
|
||||
|
||||
return path;
|
||||
}
|
||||
@@ -568,7 +572,7 @@ CFStringRef copy_developer_disk_image_path(AMDeviceRef device) {
|
||||
CFRelease(version_parts);
|
||||
CFRelease(build);
|
||||
if (path == NULL)
|
||||
on_error("Unable to locate DeveloperDiskImage.dmg. This probably means you don't have Xcode installed, you will need to launch the app manually and logging output will not be shown!");
|
||||
on_error(@"Unable to locate DeveloperDiskImage.dmg. This probably means you don't have Xcode installed, you will need to launch the app manually and logging output will not be shown!");
|
||||
|
||||
return path;
|
||||
}
|
||||
@@ -577,11 +581,11 @@ void mount_callback(CFDictionaryRef dict, int arg) {
|
||||
CFStringRef status = CFDictionaryGetValue(dict, CFSTR("Status"));
|
||||
|
||||
if (CFEqual(status, CFSTR("LookingUpImage"))) {
|
||||
printf("[ 0%%] Looking up developer disk image\n");
|
||||
NSLogOut(@"[ 0%%] Looking up developer disk image");
|
||||
} else if (CFEqual(status, CFSTR("CopyingImage"))) {
|
||||
printf("[ 30%%] Copying DeveloperDiskImage.dmg to device\n");
|
||||
NSLogOut(@"[ 30%%] Copying DeveloperDiskImage.dmg to device");
|
||||
} else if (CFEqual(status, CFSTR("MountingImage"))) {
|
||||
printf("[ 90%%] Mounting developer disk image\n");
|
||||
NSLogOut(@"[ 90%%] Mounting developer disk image");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -591,8 +595,8 @@ void mount_developer_image(AMDeviceRef device) {
|
||||
CFStringRef sig_path = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@.signature"), image_path);
|
||||
|
||||
if (verbose) {
|
||||
printf("Device support path: %s\n", CFStringGetCStringPtr(ds_path, CFStringGetSystemEncoding()));
|
||||
printf("Developer disk image: %s\n", CFStringGetCStringPtr(image_path, CFStringGetSystemEncoding()));
|
||||
NSLogOut(@"Device support path: %@", ds_path);
|
||||
NSLogOut(@"Developer disk image: %@", image_path);
|
||||
}
|
||||
CFRelease(ds_path);
|
||||
|
||||
@@ -610,11 +614,11 @@ void mount_developer_image(AMDeviceRef device) {
|
||||
|
||||
int result = AMDeviceMountImage(device, image_path, options, &mount_callback, 0);
|
||||
if (result == 0) {
|
||||
printf("[ 95%%] Developer disk image mounted successfully\n");
|
||||
NSLogOut(@"[ 95%%] Developer disk image mounted successfully");
|
||||
} else if (result == 0xe8000076 /* already mounted */) {
|
||||
printf("[ 95%%] Developer disk image already mounted\n");
|
||||
NSLogOut(@"[ 95%%] Developer disk image already mounted");
|
||||
} else {
|
||||
on_error("Unable to mount developer disk image. (%x)", result);
|
||||
on_error(@"Unable to mount developer disk image. (%x)", result);
|
||||
}
|
||||
|
||||
CFRelease(image_path);
|
||||
@@ -630,7 +634,7 @@ mach_error_t transfer_callback(CFDictionaryRef dict, int arg) {
|
||||
CFStringRef path = CFDictionaryGetValue(dict, CFSTR("Path"));
|
||||
|
||||
if ((last_path == NULL || !CFEqual(path, last_path)) && !CFStringHasSuffix(path, CFSTR(".ipa"))) {
|
||||
printf("[%3d%%] Copying %s to device\n", percent / 2, CFStringGetCStringPtr(path, kCFStringEncodingMacRoman));
|
||||
NSLogOut(@"[%3d%%] Copying %@ to device", percent / 2, path);
|
||||
}
|
||||
|
||||
if (last_path != NULL) {
|
||||
@@ -647,7 +651,7 @@ mach_error_t install_callback(CFDictionaryRef dict, int arg) {
|
||||
CFStringRef status = CFDictionaryGetValue(dict, CFSTR("Status"));
|
||||
CFNumberGetValue(CFDictionaryGetValue(dict, CFSTR("PercentComplete")), kCFNumberSInt32Type, &percent);
|
||||
|
||||
printf("[%3d%%] %s\n", (percent / 2) + 50, CFStringGetCStringPtr(status, kCFStringEncodingMacRoman));
|
||||
NSLogOut(@"[%3d%%] %@", (percent / 2) + 50, status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -998,15 +1002,15 @@ void setup_lldb(AMDeviceRef device, CFURLRef url) {
|
||||
check_error(AMDeviceValidatePairing(device));
|
||||
check_error(AMDeviceStartSession(device));
|
||||
|
||||
printf("------ Debug phase ------\n");
|
||||
NSLogOut(@"------ Debug phase ------");
|
||||
|
||||
if(AMDeviceGetInterfaceType(device) == 2)
|
||||
{
|
||||
printf("Cannot debug %s over %s.\n", CFStringGetCStringPtr(device_full_name, CFStringGetSystemEncoding()), CFStringGetCStringPtr(device_interface_name, CFStringGetSystemEncoding()));
|
||||
NSLogOut(@"Cannot debug %@ over %@.", device_full_name, device_interface_name);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
printf("Starting debug of %s connected through %s...\n", CFStringGetCStringPtr(device_full_name, CFStringGetSystemEncoding()), CFStringGetCStringPtr(device_interface_name, CFStringGetSystemEncoding()));
|
||||
NSLogOut(@"Starting debug of %@ connected through %@...", device_full_name, device_interface_name);
|
||||
|
||||
mount_developer_image(device); // put debugserver on the device
|
||||
start_remote_debug_server(device); // start debugserver
|
||||
@@ -1014,8 +1018,8 @@ void setup_lldb(AMDeviceRef device, CFURLRef url) {
|
||||
|
||||
CFRelease(url);
|
||||
|
||||
printf("[100%%] Connecting to remote debug server\n");
|
||||
printf("-------------------------\n");
|
||||
NSLogOut(@"[100%%] Connecting to remote debug server");
|
||||
NSLogOut(@"-------------------------");
|
||||
|
||||
setpgid(getpid(), 0);
|
||||
signal(SIGHUP, killed);
|
||||
@@ -1065,7 +1069,7 @@ void launch_debugger(AMDeviceRef device, CFURLRef url) {
|
||||
} else if (pid > 0) {
|
||||
child = pid;
|
||||
} else {
|
||||
on_sys_error("Fork failed");
|
||||
on_sys_error(@"Fork failed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1101,9 +1105,9 @@ void launch_debugger_and_exit(AMDeviceRef device, CFURLRef url) {
|
||||
} else if (pid > 0) {
|
||||
child = pid;
|
||||
if (verbose)
|
||||
printf("Waiting for child [Child: %d][Parent: %d]\n", child, parent);
|
||||
NSLogOut(@"Waiting for child [Child: %d][Parent: %d]\n", child, parent);
|
||||
} else {
|
||||
on_sys_error("Fork failed");
|
||||
on_sys_error(@"Fork failed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1155,7 +1159,7 @@ void read_dir(service_conn_t afcFd, afc_connection* afc_conn_p, const char* dir,
|
||||
AFCConnectionOpen(afcFd, 0, &afc_conn_p);
|
||||
}
|
||||
|
||||
printf("%s\n", dir);
|
||||
NSLogOut(@"%@", [NSString stringWithUTF8String:dir]);
|
||||
|
||||
afc_dictionary* afc_dict_p;
|
||||
char *key, *val;
|
||||
@@ -1222,15 +1226,13 @@ service_conn_t start_house_arrest_service(AMDeviceRef device) {
|
||||
service_conn_t houseFd;
|
||||
|
||||
if (bundle_id == NULL) {
|
||||
printf("Bundle id is not specified\n");
|
||||
exit(1);
|
||||
on_error(@"Bundle id is not specified");
|
||||
}
|
||||
|
||||
CFStringRef cf_bundle_id = CFStringCreateWithCString(NULL, bundle_id, kCFStringEncodingASCII);
|
||||
if (AMDeviceStartHouseArrestService(device, cf_bundle_id, 0, &houseFd, 0) != 0)
|
||||
{
|
||||
printf("Unable to find bundle with id: %s\n", bundle_id);
|
||||
exit(1);
|
||||
on_error(@"Unable to find bundle with id: %@", bundle_id);
|
||||
}
|
||||
|
||||
check_error(AMDeviceStopSession(device));
|
||||
@@ -1268,7 +1270,7 @@ void* read_file_to_memory(char * path, size_t* file_size)
|
||||
*file_size = buf.st_size;
|
||||
FILE* fd = fopen(path, "r");
|
||||
char* content = malloc(*file_size);
|
||||
if (fread(content, *file_size, 1, fd) != 1)
|
||||
if (*file_size != 0 && fread(content, *file_size, 1, fd) != 1)
|
||||
{
|
||||
fclose(fd);
|
||||
return NULL;
|
||||
@@ -1291,7 +1293,7 @@ void list_files(AMDeviceRef device)
|
||||
int app_exists(AMDeviceRef device)
|
||||
{
|
||||
if (bundle_id == NULL) {
|
||||
printf("Bundle id is not specified\n");
|
||||
NSLogOut(@"Bundle id is not specified.");
|
||||
return 1;
|
||||
}
|
||||
AMDeviceConnect(device);
|
||||
@@ -1307,9 +1309,8 @@ int app_exists(AMDeviceRef device)
|
||||
CFDictionaryRef result = nil;
|
||||
check_error(AMDeviceLookupApplications(device, options, &result));
|
||||
|
||||
CFDictionaryRef app_dict = CFDictionaryGetValue(result, cf_bundle_id);
|
||||
bool appExists = (app_dict == NULL) ? false : true;
|
||||
printf("%s", appExists ? "true\n" : "false\n");
|
||||
bool appExists = CFDictionaryContainsKey(result, cf_bundle_id);
|
||||
NSLogOut(@"%@", appExists ? @"true" : @"false");
|
||||
CFRelease(cf_bundle_id);
|
||||
|
||||
check_error(AMDeviceStopSession(device));
|
||||
@@ -1319,6 +1320,32 @@ int app_exists(AMDeviceRef device)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void list_bundle_id(AMDeviceRef device)
|
||||
{
|
||||
AMDeviceConnect(device);
|
||||
assert(AMDeviceIsPaired(device));
|
||||
check_error(AMDeviceValidatePairing(device));
|
||||
check_error(AMDeviceStartSession(device));
|
||||
|
||||
NSArray *a = [NSArray arrayWithObjects:@"CFBundleIdentifier", nil];
|
||||
NSDictionary *optionsDict = [NSDictionary dictionaryWithObject:a forKey:@"ReturnAttributes"];
|
||||
CFDictionaryRef options = (CFDictionaryRef)optionsDict;
|
||||
CFDictionaryRef result = nil;
|
||||
check_error(AMDeviceLookupApplications(device, options, &result));
|
||||
|
||||
CFIndex count;
|
||||
count = CFDictionaryGetCount(result);
|
||||
const void *keys[count];
|
||||
CFDictionaryGetKeysAndValues(result, keys, NULL);
|
||||
for(int i = 0; i < count; ++i) {
|
||||
CFStringRef test = (CFStringRef)keys[i];
|
||||
NSLogOut(@"%@", (CFStringRef)keys[i]);
|
||||
}
|
||||
|
||||
check_error(AMDeviceStopSession(device));
|
||||
check_error(AMDeviceDisconnect(device));
|
||||
}
|
||||
|
||||
void copy_file_callback(afc_connection* afc_conn_p, const char *name,int file)
|
||||
{
|
||||
const char *local_name=name;
|
||||
@@ -1360,25 +1387,13 @@ void copy_file_callback(afc_connection* afc_conn_p, const char *name,int file)
|
||||
}
|
||||
}
|
||||
|
||||
void mkdirhier(char *path)
|
||||
{
|
||||
char *slash;
|
||||
struct stat buf;
|
||||
|
||||
if (path[0]=='.' && path[1]=='/') path+=2;
|
||||
|
||||
if ((slash = strrchr(path,'/'))) {
|
||||
*slash = '\0';
|
||||
if (stat(path,&buf)==0) {
|
||||
*slash = '/';
|
||||
return;
|
||||
}
|
||||
mkdirhier(path);
|
||||
mkdir (path,0777);
|
||||
*slash = '/';
|
||||
}
|
||||
|
||||
return;
|
||||
BOOL mkdirp(NSString* path) {
|
||||
NSError* error = nil;
|
||||
BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:path
|
||||
withIntermediateDirectories:YES
|
||||
attributes:nil
|
||||
error:&error];
|
||||
return success;
|
||||
}
|
||||
|
||||
void download_tree(AMDeviceRef device)
|
||||
@@ -1386,12 +1401,15 @@ void download_tree(AMDeviceRef device)
|
||||
service_conn_t houseFd = start_house_arrest_service(device);
|
||||
afc_connection* afc_conn_p = NULL;
|
||||
char *dirname = NULL;
|
||||
|
||||
NSString* targetPath = [NSString pathWithComponents:@[ @(target_filename), @(list_root)] ];
|
||||
mkdirp([targetPath stringByDeletingLastPathComponent]);
|
||||
|
||||
if (AFCConnectionOpen(houseFd, 0, &afc_conn_p) == 0) do {
|
||||
|
||||
if (target_filename) {
|
||||
dirname = strdup(target_filename);
|
||||
mkdirhier(dirname);
|
||||
mkdirp(@(dirname));
|
||||
if (mkdir(dirname,0777) && errno!=EEXIST) {
|
||||
fprintf(stderr,"mkdir(\"%s\") failed: %s\n",dirname,strerror(errno));
|
||||
break;
|
||||
@@ -1431,8 +1449,7 @@ void upload_file(AMDeviceRef device) {
|
||||
|
||||
if (!file_content)
|
||||
{
|
||||
printf("Could not open file: %s\n", upload_pathname);
|
||||
exit(-1);
|
||||
on_error(@"Could not open file: %@", upload_pathname);
|
||||
}
|
||||
|
||||
// Make sure the directory was created
|
||||
@@ -1452,12 +1469,10 @@ void upload_file(AMDeviceRef device) {
|
||||
|
||||
int ret = AFCFileRefOpen(afc_conn_p, target_filename, 3, &file_ref);
|
||||
if (ret == 0x000a) {
|
||||
printf("Cannot write to %s. Permission error.\n", target_filename);
|
||||
exit(1);
|
||||
on_error(@"Cannot write to %@. Permission error.", [NSString stringWithUTF8String:target_filename]);
|
||||
}
|
||||
if (ret == 0x0009) {
|
||||
printf("Target %s is a directory.\n", target_filename);
|
||||
exit(1);
|
||||
on_error(@"Target %@ is a directory.", [NSString stringWithUTF8String:target_filename]);
|
||||
}
|
||||
assert(ret == 0);
|
||||
assert(AFCFileRefWrite(afc_conn_p, file_ref, file_content, file_size) == 0);
|
||||
@@ -1497,7 +1512,7 @@ void remove_path(AMDeviceRef device) {
|
||||
void uninstall_app(AMDeviceRef device) {
|
||||
CFRetain(device); // don't know if this is necessary?
|
||||
|
||||
printf("------ Uninstall phase ------\n");
|
||||
NSLogOut(@"------ Uninstall phase ------");
|
||||
|
||||
//Do we already have the bundle_id passed in via the command line? if so, use it.
|
||||
CFStringRef cf_uninstall_bundle_id = NULL;
|
||||
@@ -1505,12 +1520,11 @@ void uninstall_app(AMDeviceRef device) {
|
||||
{
|
||||
cf_uninstall_bundle_id = CFStringCreateWithCString(NULL, bundle_id, kCFStringEncodingASCII);
|
||||
} else {
|
||||
printf ("Error: you need to pass in the bundle id, (i.e. --bundle_id com.my.app)");
|
||||
exit(1);
|
||||
on_error(@"Error: you need to pass in the bundle id, (i.e. --bundle_id com.my.app)");
|
||||
}
|
||||
|
||||
if (cf_uninstall_bundle_id == NULL) {
|
||||
printf("Error: Unable to get bundle id from user command or package %s\n Uninstall failed\n", app_path);
|
||||
on_error(@"Error: Unable to get bundle id from user command or package %@.\nUninstall failed.", app_path);
|
||||
} else {
|
||||
AMDeviceConnect(device);
|
||||
assert(AMDeviceIsPaired(device));
|
||||
@@ -1519,9 +1533,9 @@ void uninstall_app(AMDeviceRef device) {
|
||||
|
||||
int code = AMDeviceSecureUninstallApplication(0, device, cf_uninstall_bundle_id, 0, NULL, 0);
|
||||
if (code == 0) {
|
||||
printf("[ OK ] Uninstalled package with bundle id %s\n", CFStringGetCStringPtr(cf_uninstall_bundle_id, CFStringGetSystemEncoding()));
|
||||
NSLogOut(@"[ OK ] Uninstalled package with bundle id %@", cf_uninstall_bundle_id);
|
||||
} else {
|
||||
printf("[ ERROR ] Could not uninstall package with bundle id %s\n", CFStringGetCStringPtr(cf_uninstall_bundle_id, CFStringGetSystemEncoding()));
|
||||
on_error(@"[ ERROR ] Could not uninstall package with bundle id %@", cf_uninstall_bundle_id);
|
||||
}
|
||||
check_error(AMDeviceStopSession(device));
|
||||
check_error(AMDeviceDisconnect(device));
|
||||
@@ -1537,15 +1551,17 @@ void handle_device(AMDeviceRef device) {
|
||||
device_interface_name = get_device_interface_name(device);
|
||||
|
||||
if (detect_only) {
|
||||
CFShow([NSString stringWithFormat:@"[....] Found %@ connected through %@.\n", device_full_name, device_interface_name]);
|
||||
NSLogOut(@"[....] Found %@ connected through %@.", device_full_name, device_interface_name);
|
||||
found_device = true;
|
||||
return;
|
||||
}
|
||||
if (device_id != NULL) {
|
||||
if(strcmp(device_id, CFStringGetCStringPtr(found_device_id, CFStringGetSystemEncoding())) == 0) {
|
||||
CFStringRef deviceCFSTR = CFStringCreateWithCString(NULL, device_id, kCFStringEncodingASCII);
|
||||
if (CFStringCompare(deviceCFSTR, found_device_id, kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
|
||||
found_device = true;
|
||||
CFRelease(deviceCFSTR);
|
||||
} else {
|
||||
CFShow([NSString stringWithFormat:@"Skipping %@.\n", device_full_name]);
|
||||
NSLogOut(@"Skipping %@.", device_full_name);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -1553,7 +1569,7 @@ void handle_device(AMDeviceRef device) {
|
||||
found_device = true;
|
||||
}
|
||||
|
||||
CFShow([NSString stringWithFormat:@"[....] Using %@ (%@).\n", device_full_name, found_device_id]);
|
||||
NSLogOut(@"[....] Using %@.", device_full_name);
|
||||
|
||||
if (command_only) {
|
||||
if (strcmp("list", command) == 0) {
|
||||
@@ -1561,7 +1577,7 @@ void handle_device(AMDeviceRef device) {
|
||||
} else if (strcmp("upload", command) == 0) {
|
||||
upload_file(device);
|
||||
} else if (strcmp("download", command) == 0) {
|
||||
download_tree(device);
|
||||
download_tree(device);
|
||||
} else if (strcmp("mkdir", command) == 0) {
|
||||
make_directory(device);
|
||||
} else if (strcmp("rm", command) == 0) {
|
||||
@@ -1570,6 +1586,8 @@ void handle_device(AMDeviceRef device) {
|
||||
exit(app_exists(device));
|
||||
} else if (strcmp("uninstall_only", command) == 0) {
|
||||
uninstall_app(device);
|
||||
} else if (strcmp("list_bundle_id", command) == 0) {
|
||||
list_bundle_id(device);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
@@ -1584,7 +1602,7 @@ void handle_device(AMDeviceRef device) {
|
||||
CFRelease(relative_url);
|
||||
|
||||
if (uninstall) {
|
||||
printf("------ Uninstall phase ------\n");
|
||||
NSLogOut(@"------ Uninstall phase ------");
|
||||
|
||||
//Do we already have the bundle_id passed in via the command line? if so, use it.
|
||||
CFStringRef cf_uninstall_bundle_id = NULL;
|
||||
@@ -1596,7 +1614,7 @@ void handle_device(AMDeviceRef device) {
|
||||
}
|
||||
|
||||
if (cf_uninstall_bundle_id == NULL) {
|
||||
printf("Error: Unable to get bundle id from user command or package %s\n Uninstall failed\n", app_path);
|
||||
on_error(@"Error: Unable to get bundle id from user command or package %@.\nUninstall failed.", app_path);
|
||||
} else {
|
||||
AMDeviceConnect(device);
|
||||
assert(AMDeviceIsPaired(device));
|
||||
@@ -1605,9 +1623,9 @@ void handle_device(AMDeviceRef device) {
|
||||
|
||||
int code = AMDeviceSecureUninstallApplication(0, device, cf_uninstall_bundle_id, 0, NULL, 0);
|
||||
if (code == 0) {
|
||||
printf("[ OK ] Uninstalled package with bundle id %s\n", CFStringGetCStringPtr(cf_uninstall_bundle_id, CFStringGetSystemEncoding()));
|
||||
NSLogOut(@"[ OK ] Uninstalled package with bundle id %@", cf_uninstall_bundle_id);
|
||||
} else {
|
||||
printf("[ ERROR ] Could not uninstall package with bundle id %s\n", CFStringGetCStringPtr(cf_uninstall_bundle_id, CFStringGetSystemEncoding()));
|
||||
on_error(@"[ ERROR ] Could not uninstall package with bundle id %@", cf_uninstall_bundle_id);
|
||||
}
|
||||
check_error(AMDeviceStopSession(device));
|
||||
check_error(AMDeviceDisconnect(device));
|
||||
@@ -1615,8 +1633,8 @@ void handle_device(AMDeviceRef device) {
|
||||
}
|
||||
|
||||
if(install) {
|
||||
printf("------ Install phase ------\n");
|
||||
CFShow([NSString stringWithFormat:@"[ 0%%] Found %@ connected through %@, beginning install\n", device_full_name, device_interface_name]);
|
||||
NSLogOut(@"------ Install phase ------");
|
||||
NSLogOut(@"[ 0%%] Found %@ connected through %@, beginning install", device_full_name, device_interface_name);
|
||||
|
||||
AMDeviceConnect(device);
|
||||
assert(AMDeviceIsPaired(device));
|
||||
@@ -1664,7 +1682,7 @@ void handle_device(AMDeviceRef device) {
|
||||
CFRelease(path);
|
||||
CFRelease(options);
|
||||
|
||||
printf("[100%%] Installed package %s\n", app_path);
|
||||
NSLogOut(@"[100%%] Installed package %@", [NSString stringWithUTF8String:app_path]);
|
||||
}
|
||||
|
||||
if (!debug)
|
||||
@@ -1700,12 +1718,12 @@ void timeout_callback(CFRunLoopTimerRef timer, void *info) {
|
||||
}
|
||||
|
||||
if(!found_device)
|
||||
on_error("Timed out waiting for device.");
|
||||
on_error(@"Timed out waiting for device.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!debug) {
|
||||
printf("[....] No more devices found.\n");
|
||||
NSLogOut(@"[....] No more devices found.");
|
||||
}
|
||||
|
||||
if (detect_only && !found_device) {
|
||||
@@ -1717,7 +1735,7 @@ void timeout_callback(CFRunLoopTimerRef timer, void *info) {
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
printf("Timeout. Killing child (%d) tree\n", child);
|
||||
NSLogOut(@"Timeout. Killing child (%d) tree.", child);
|
||||
}
|
||||
kill_ptree(child, SIGHUP);
|
||||
}
|
||||
@@ -1727,37 +1745,38 @@ void timeout_callback(CFRunLoopTimerRef timer, void *info) {
|
||||
}
|
||||
|
||||
void usage(const char* app) {
|
||||
printf(
|
||||
"Usage: %s [OPTION]...\n"
|
||||
" -d, --debug launch the app in lldb after installation\n"
|
||||
" -i, --id <device_id> the id of the device to connect to\n"
|
||||
" -c, --detect only detect if the device is connected\n"
|
||||
" -b, --bundle <bundle.app> the path to the app bundle to be installed\n"
|
||||
" -a, --args <args> command line arguments to pass to the app when launching it\n"
|
||||
" -t, --timeout <timeout> number of seconds to wait for a device to be connected\n"
|
||||
" -u, --unbuffered don't buffer stdout\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 <number> port used for device, default: dynamic\n"
|
||||
" -r, --uninstall uninstall the app before install (do not use with -m; app cache and data are cleared) \n"
|
||||
" -9, --uninstall_only uninstall the app ONLY. Use only with -1 <bundle_id> \n"
|
||||
" -1, --bundle_id <bundle id> specify bundle id for list and upload\n"
|
||||
" -l, --list list files\n"
|
||||
" -o, --upload <file> upload file\n"
|
||||
" -w, --download download app tree\n"
|
||||
" -2, --to <target pathname> use together with up/download file/tree. specify target\n"
|
||||
" -D, --mkdir <dir> make directory on device\n"
|
||||
" -R, --rm <path> remove file or directory on device (directories must be empty)\n"
|
||||
" -V, --version print the executable version \n"
|
||||
" -e, --exists check if the app with given bundle_id is installed or not \n",
|
||||
app);
|
||||
NSLog(
|
||||
@"Usage: %@ [OPTION]...\n"
|
||||
@" -d, --debug launch the app in lldb after installation\n"
|
||||
@" -i, --id <device_id> the id of the device to connect to\n"
|
||||
@" -c, --detect only detect if the device is connected\n"
|
||||
@" -b, --bundle <bundle.app> the path to the app bundle to be installed\n"
|
||||
@" -a, --args <args> command line arguments to pass to the app when launching it\n"
|
||||
@" -t, --timeout <timeout> number of seconds to wait for a device to be connected\n"
|
||||
@" -u, --unbuffered don't buffer stdout\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 <number> port used for device, default: dynamic\n"
|
||||
@" -r, --uninstall uninstall the app before install (do not use with -m; app cache and data are cleared) \n"
|
||||
@" -9, --uninstall_only uninstall the app ONLY. Use only with -1 <bundle_id> \n"
|
||||
@" -1, --bundle_id <bundle id> specify bundle id for list and upload\n"
|
||||
@" -l, --list list files\n"
|
||||
@" -o, --upload <file> upload file\n"
|
||||
@" -w, --download download app tree\n"
|
||||
@" -2, --to <target pathname> use together with up/download file/tree. specify target\n"
|
||||
@" -D, --mkdir <dir> make directory on device\n"
|
||||
@" -R, --rm <path> remove file or directory on device (directories must be empty)\n"
|
||||
@" -V, --version print the executable version \n"
|
||||
@" -e, --exists check if the app with given bundle_id is installed or not \n"
|
||||
@" -B, --list_bundle_id list bundle_id \n",
|
||||
[NSString stringWithUTF8String:app]);
|
||||
}
|
||||
|
||||
void show_version() {
|
||||
printf("%s\n", APP_VERSION);
|
||||
NSLogOut(@"%@", APP_VERSION);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
@@ -1786,11 +1805,12 @@ int main(int argc, char *argv[]) {
|
||||
{ "mkdir", required_argument, NULL, 'D'},
|
||||
{ "rm", required_argument, NULL, 'R'},
|
||||
{ "exists", no_argument, NULL, 'e'},
|
||||
{ "list_bundle_id", no_argument, NULL, 'B'},
|
||||
{ NULL, 0, NULL, 0 },
|
||||
};
|
||||
char ch;
|
||||
|
||||
while ((ch = getopt_long(argc, argv, "VmcdvunrILeD:R:i:b:a:t:g:x:p:1:2:o:l::w::9::", longopts, NULL)) != -1)
|
||||
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)
|
||||
{
|
||||
switch (ch) {
|
||||
case 'm':
|
||||
@@ -1823,10 +1843,12 @@ int main(int argc, char *argv[]) {
|
||||
break;
|
||||
case 'I':
|
||||
interactive = false;
|
||||
debug = 1;
|
||||
break;
|
||||
case 'L':
|
||||
interactive = false;
|
||||
justlaunch = true;
|
||||
debug = 1;
|
||||
break;
|
||||
case 'c':
|
||||
detect_only = true;
|
||||
@@ -1880,6 +1902,10 @@ int main(int argc, char *argv[]) {
|
||||
command_only = true;
|
||||
command = "exists";
|
||||
break;
|
||||
case 'B':
|
||||
command_only = true;
|
||||
command = "list_bundle_id";
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
return exitcode_error;
|
||||
@@ -1888,7 +1914,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|e|9] is required to proceed!");
|
||||
}
|
||||
|
||||
if (unbuffered) {
|
||||
@@ -1902,7 +1928,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
if (app_path) {
|
||||
if (access(app_path, F_OK) != 0) {
|
||||
on_sys_error("Can't access app path '%s'", app_path);
|
||||
on_sys_error(@"Can't access app path '%@'", app_path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1911,11 +1937,11 @@ int main(int argc, char *argv[]) {
|
||||
{
|
||||
CFRunLoopTimerRef timer = CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent() + timeout, 0, 0, 0, timeout_callback, NULL);
|
||||
CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopCommonModes);
|
||||
printf("[....] Waiting up to %d seconds for iOS device to be connected\n", timeout);
|
||||
NSLogOut(@"[....] Waiting up to %d seconds for iOS device to be connected", timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("[....] Waiting for iOS device to be connected\n");
|
||||
NSLogOut(@"[....] Waiting for iOS device to be connected");
|
||||
}
|
||||
|
||||
struct am_device_notification *notify;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ios-deploy",
|
||||
"version": "1.6.2",
|
||||
"version": "1.7.0",
|
||||
"os" : [ "darwin" ],
|
||||
"description": "launch iOS apps iOS devices from the command line (Xcode 6)",
|
||||
"main": "ios-deploy",
|
||||
|
||||
Reference in New Issue
Block a user