17 Commits
main ... 1.9.0

Author SHA1 Message Date
Shazron Abdullah
4346b331b7 Updated version to 1.9.0 2016-09-16 02:59:01 -07:00
Shazron Abdullah
baa524eda5 Fixes #250 - Can't pass in command line args to the iOS application
Thanks to https://github.com/dot-asm
2016-09-16 02:55:19 -07:00
Shazron Abdullah
66ca97ef12 Add iPad Pro friendly names
This closes #252
2016-09-16 02:55:07 -07:00
Shazron Abdullah
e8bbb96de2 Added iPhone 7 and 7 Plus friendly names
This closes #251
2016-09-16 02:54:52 -07:00
Shazron Abdullah
928635e44f Added new iPhone SE friendly name 2016-09-16 02:54:39 -07:00
Shazron Abdullah
99efb11c3d Added tvOS Apple TV 4G friendly name
This closes #248

Thanks to https://github.com/gusc
2016-09-16 02:54:25 -07:00
Thierry Berger
b4b17cc722 added support for AppleTV OS ; simplified find_path() to avoid quoting root_path (some paths weren't working) 2016-09-16 02:28:04 -07:00
Shazron Abdullah
2ed9a17914 Updated version to 1.8.7 2016-09-14 02:57:36 -07:00
Shazron Abdullah
feb51d582a Fixes #240 - IndexError: list index out of range
Thanks to https://github.com/gusc (Gusts Kaksis) for the patch.
2016-09-14 02:16:12 -07:00
Shazron Abdullah
d7cccae1ad Increased version to 1.8.6 2016-04-11 14:14:04 -07:00
Alexis Kofman
9871c759e0 Fixes #219 - iOS 9.3 app hangs on splash screen
Fixes cases where process is not yet running.

Signed-off-by: Shazron Abdullah <shazron@apache.org>
2016-04-11 14:11:57 -07:00
Steve Moser
956e925f97 Update for iPhone SE
https://twitter.com/panzer/status/712330579291668480
2016-04-08 18:33:50 -07:00
Alexis Kofman
c769f3cf58 rm autogenerated files from the repo 2016-04-08 18:08:37 -07:00
Alexis Kofman
440454fc5a replace remaining tabs by spaces 2016-04-08 18:08:24 -07:00
Shazron Abdullah
c4cd7b4a55 Increment version to 1.8.5 2016-02-04 09:45:50 -08:00
Shazron Abdullah
d688e29975 Added warning text to the check_reqs.js log when running under OS X 10.11 El Capitan 2016-02-04 09:33:59 -08:00
Steven Kramer
7b07c2e28d Added support for recursive directory uploads 2016-01-19 17:08:05 -08:00
8 changed files with 321 additions and 262 deletions

2
.gitignore vendored
View File

@@ -2,3 +2,5 @@ build/*
node_modules/* node_modules/*
/.DS_Store /.DS_Store
*~ *~
src/scripts/lldb.pyc
src/ios-deploy/lldb.py.h

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7E8E3A821C45D4CE0017F6C1"
BuildableName = "ios-deploy-tests.xctest"
BlueprintName = "ios-deploy-tests"
ReferencedContainer = "container:ios-deploy.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -1,6 +1,6 @@
{ {
"name": "ios-deploy", "name": "ios-deploy",
"version": "1.8.4", "version": "1.9.0",
"os": [ "os": [
"darwin" "darwin"
], ],
@@ -18,7 +18,7 @@
}, },
"scripts": { "scripts": {
"preinstall": "./src/scripts/check_reqs.js && xcodebuild", "preinstall": "./src/scripts/check_reqs.js && xcodebuild",
"test": "npm run pycompile && npm run jshint && xcodebuild -scheme ios-deploy-lib && xcodebuild test -scheme ios-deploy-tests", "test": "npm run pycompile && npm run jshint && xcodebuild -target ios-deploy-lib && xcodebuild test -scheme ios-deploy-tests",
"jshint": "node node_modules/jshint/bin/jshint src/scripts/*.js", "jshint": "node node_modules/jshint/bin/jshint src/scripts/*.js",
"pycompile": "python -m py_compile src/scripts/*.py" "pycompile": "python -m py_compile src/scripts/*.py"
}, },

View File

@@ -76,8 +76,8 @@ int AMDeviceGetInterfaceType(struct am_device *device);
bool found_device = false, debug = false, verbose = false, unbuffered = false, nostart = false, detect_only = false, install = true, uninstall = false, no_wifi = false; bool found_device = false, debug = false, verbose = false, unbuffered = false, nostart = false, detect_only = false, install = true, uninstall = false, no_wifi = false;
bool command_only = false; bool command_only = false;
char *command = NULL; char *command = NULL;
char *target_filename = NULL; char const*target_filename = NULL;
char *upload_pathname = NULL; char const*upload_pathname = NULL;
char *bundle_id = NULL; char *bundle_id = NULL;
bool interactive = true; bool interactive = true;
bool justlaunch = false; bool justlaunch = false;
@@ -86,7 +86,7 @@ char *device_id = NULL;
char *args = NULL; char *args = NULL;
char *list_root = NULL; char *list_root = NULL;
int _timeout = 0; int _timeout = 0;
int port = 0; // 0 means "dynamically assigned" int port = 0; // 0 means "dynamically assigned"
CFStringRef last_path = NULL; CFStringRef last_path = NULL;
service_conn_t gdbfd; service_conn_t gdbfd;
pid_t parent = 0; pid_t parent = 0;
@@ -122,8 +122,8 @@ void on_error(NSString* format, ...)
NSString* str = [[[NSString alloc] initWithFormat:format arguments:valist] autorelease]; NSString* str = [[[NSString alloc] initWithFormat:format arguments:valist] autorelease];
va_end(valist); va_end(valist);
NSLog(@"[ !! ] %@", str); NSLog(@"[ !! ] %@", str);
exit(exitcode_error); exit(exitcode_error);
} }
@@ -135,7 +135,7 @@ void on_sys_error(NSString* format, ...) {
va_start(valist, format); va_start(valist, format);
NSString* str = [[[NSString alloc] initWithFormat:format arguments:valist] autorelease]; NSString* str = [[[NSString alloc] initWithFormat:format arguments:valist] autorelease];
va_end(valist); va_end(valist);
on_error(@"%@ : %@", str, [NSString stringWithUTF8String:errstr]); on_error(@"%@ : %@", str, [NSString stringWithUTF8String:errstr]);
} }
@@ -147,25 +147,25 @@ void __NSLogOut(NSString* format, va_list valist) {
void NSLogOut(NSString* format, ...) { void NSLogOut(NSString* format, ...) {
va_list valist; va_list valist;
va_start(valist, format); va_start(valist, format);
__NSLogOut(format, valist); __NSLogOut(format, valist);
va_end(valist); va_end(valist);
} }
void NSLogVerbose(NSString* format, ...) { void NSLogVerbose(NSString* format, ...) {
if (verbose) { if (verbose) {
va_list valist; va_list valist;
va_start(valist, format); va_start(valist, format);
__NSLogOut(format, valist); __NSLogOut(format, valist);
va_end(valist); va_end(valist);
} }
} }
BOOL mkdirp(NSString* path) { BOOL mkdirp(NSString* path) {
NSError* error = nil; NSError* error = nil;
BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:path BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:path
withIntermediateDirectories:YES withIntermediateDirectories:YES
attributes:nil attributes:nil
error:&error]; error:&error];
return success; return success;
} }
@@ -185,23 +185,14 @@ Boolean path_exists(CFTypeRef path) {
CFStringRef find_path(CFStringRef rootPath, CFStringRef namePattern, CFStringRef expression) { CFStringRef find_path(CFStringRef rootPath, CFStringRef namePattern, CFStringRef expression) {
FILE *fpipe = NULL; FILE *fpipe = NULL;
CFStringRef quotedRootPath = rootPath;
CFStringRef cf_command; CFStringRef cf_command;
CFRange slashLocation; CFRange slashLocation;
if (CFStringGetCharacterAtIndex(rootPath, 0) != '`') {
quotedRootPath = CFStringCreateWithFormat(NULL, NULL, CFSTR("'%@'"), rootPath);
}
slashLocation = CFStringFind(namePattern, CFSTR("/"), 0); slashLocation = CFStringFind(namePattern, CFSTR("/"), 0);
if (slashLocation.location == kCFNotFound) { if (slashLocation.location == kCFNotFound) {
cf_command = CFStringCreateWithFormat(NULL, NULL, CFSTR("find %@ -name '%@' %@ 2>/dev/null | sort | tail -n 1"), quotedRootPath, namePattern, expression); cf_command = CFStringCreateWithFormat(NULL, NULL, CFSTR("find %@ -name '%@' %@ 2>/dev/null | sort | tail -n 1"), rootPath, namePattern, expression);
} else { } else {
cf_command = CFStringCreateWithFormat(NULL, NULL, CFSTR("find %@ -path '%@' %@ 2>/dev/null | sort | tail -n 1"), quotedRootPath, namePattern, expression); cf_command = CFStringCreateWithFormat(NULL, NULL, CFSTR("find %@ -path '%@' %@ 2>/dev/null | sort | tail -n 1"), rootPath, namePattern, expression);
}
if (quotedRootPath != rootPath) {
CFRelease(quotedRootPath);
} }
char command[1024] = { '\0' }; char command[1024] = { '\0' };
@@ -331,6 +322,13 @@ const CFStringRef get_device_hardware_name(const AMDeviceRef device) {
GET_FRIENDLY_MODEL_NAME(model, "P102AP", "iPad 4 (GSM)") GET_FRIENDLY_MODEL_NAME(model, "P102AP", "iPad 4 (GSM)")
GET_FRIENDLY_MODEL_NAME(model, "P103AP", "iPad 4 (CDMA)") GET_FRIENDLY_MODEL_NAME(model, "P103AP", "iPad 4 (CDMA)")
// iPad Pro
GET_FRIENDLY_MODEL_NAME(model, "J98aAP", "iPad Pro (12.9\")")
GET_FRIENDLY_MODEL_NAME(model, "J98aAP", "iPad Pro (12.9\")")
GET_FRIENDLY_MODEL_NAME(model, "J127AP", "iPad Pro (9.7\")")
GET_FRIENDLY_MODEL_NAME(model, "J128AP", "iPad Pro (9.7\")")
// iPad Mini // iPad Mini
GET_FRIENDLY_MODEL_NAME(model, "P105AP", "iPad mini") GET_FRIENDLY_MODEL_NAME(model, "P105AP", "iPad mini")
@@ -342,6 +340,7 @@ const CFStringRef get_device_hardware_name(const AMDeviceRef device) {
GET_FRIENDLY_MODEL_NAME(model, "K66AP", "Apple TV 2G") GET_FRIENDLY_MODEL_NAME(model, "K66AP", "Apple TV 2G")
GET_FRIENDLY_MODEL_NAME(model, "J33AP", "Apple TV 3G") GET_FRIENDLY_MODEL_NAME(model, "J33AP", "Apple TV 3G")
GET_FRIENDLY_MODEL_NAME(model, "J33IAP", "Apple TV 3.1G") GET_FRIENDLY_MODEL_NAME(model, "J33IAP", "Apple TV 3.1G")
GET_FRIENDLY_MODEL_NAME(model, "J42dAP", "Apple TV 4G")
// iPhone // iPhone
@@ -360,11 +359,18 @@ const CFStringRef get_device_hardware_name(const AMDeviceRef device) {
GET_FRIENDLY_MODEL_NAME(model, "N53AP", "iPhone 5s (Global/CDMA)") GET_FRIENDLY_MODEL_NAME(model, "N53AP", "iPhone 5s (Global/CDMA)")
GET_FRIENDLY_MODEL_NAME(model, "N61AP", "iPhone 6 (GSM)") GET_FRIENDLY_MODEL_NAME(model, "N61AP", "iPhone 6 (GSM)")
GET_FRIENDLY_MODEL_NAME(model, "N56AP", "iPhone 6 Plus") GET_FRIENDLY_MODEL_NAME(model, "N56AP", "iPhone 6 Plus")
GET_FRIENDLY_MODEL_NAME(model, "N71mAP", "iPhone 6s")
GET_FRIENDLY_MODEL_NAME(model, "N71AP", "iPhone 6s")
GET_FRIENDLY_MODEL_NAME(model, "N66AP", "iPhone 6s Plus")
GET_FRIENDLY_MODEL_NAME(model, "N66mAP", "iPhone 6s Plus")
GET_FRIENDLY_MODEL_NAME(model, "N69AP", "iPhone SE")
GET_FRIENDLY_MODEL_NAME(model, "N69uAP", "iPhone SE")
GET_FRIENDLY_MODEL_NAME(model, "N71mAP", "iPhone 6s") GET_FRIENDLY_MODEL_NAME(model, "D10AP", "iPhone 7")
GET_FRIENDLY_MODEL_NAME(model, "N71AP", "iPhone 6s") GET_FRIENDLY_MODEL_NAME(model, "D101AP", "iPhone 7")
GET_FRIENDLY_MODEL_NAME(model, "N66AP", "iPhone 6s Plus") GET_FRIENDLY_MODEL_NAME(model, "D11AP", "iPhone 7 Plus")
GET_FRIENDLY_MODEL_NAME(model, "N66mAP", "iPhone 6s Plus") GET_FRIENDLY_MODEL_NAME(model, "D111AP", "iPhone 7 Plus")
return model; return model;
} }
@@ -397,8 +403,8 @@ CFStringRef get_device_full_name(const AMDeviceRef device) {
device_name = AMDeviceCopyValue(device, 0, CFSTR("DeviceName")), device_name = AMDeviceCopyValue(device, 0, CFSTR("DeviceName")),
model_name = get_device_hardware_name(device); model_name = get_device_hardware_name(device);
NSLogVerbose(@"Device Name: %@", device_name); NSLogVerbose(@"Device Name: %@", device_name);
NSLogVerbose(@"Model Name: %@", model_name); NSLogVerbose(@"Model Name: %@", model_name);
if(device_name != NULL && model_name != NULL) if(device_name != NULL && model_name != NULL)
{ {
@@ -445,25 +451,39 @@ CFMutableArrayRef get_device_product_version_parts(AMDeviceRef device) {
CFStringRef copy_device_support_path(AMDeviceRef device) { CFStringRef copy_device_support_path(AMDeviceRef device) {
CFStringRef version = NULL; CFStringRef version = NULL;
CFStringRef build = AMDeviceCopyValue(device, 0, CFSTR("BuildVersion")); CFStringRef build = AMDeviceCopyValue(device, 0, CFSTR("BuildVersion"));
CFStringRef deviceClass = AMDeviceCopyValue(device, 0, CFSTR("DeviceClass"));
CFStringRef path = NULL; CFStringRef path = NULL;
CFMutableArrayRef version_parts = get_device_product_version_parts(device); CFMutableArrayRef version_parts = get_device_product_version_parts(device);
NSLogVerbose(@"Device Class: %@", deviceClass);
NSLogVerbose(@"build: %@", build);
CFStringRef deviceClassPath_platform;
CFStringRef deviceClassPath_alt;
if (CFStringCompare(CFSTR("AppleTV"), deviceClass, 0) == kCFCompareEqualTo) {
deviceClassPath_platform = CFSTR("Platforms/AppleTVOS.platform/DeviceSupport");
deviceClassPath_alt = CFSTR("tvOS\\ DeviceSupport");
} else {
deviceClassPath_platform = CFSTR("Platforms/iPhoneOS.platform/DeviceSupport");
deviceClassPath_alt = CFSTR("iOS\\ DeviceSupport");
}
while (CFArrayGetCount(version_parts) > 0) { while (CFArrayGetCount(version_parts) > 0) {
version = CFStringCreateByCombiningStrings(NULL, version_parts, CFSTR(".")); version = CFStringCreateByCombiningStrings(NULL, version_parts, CFSTR("."));
NSLogVerbose(@"version: %@", version);
if (path == NULL) { if (path == NULL) {
path = copy_xcode_path_for(CFSTR("iOS DeviceSupport"), CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ (%@)"), version, build)); path = copy_xcode_path_for(deviceClassPath_alt, CFStringCreateWithFormat(NULL, NULL, CFSTR("%@\\ \\(%@\\)"), version, build));
} }
if (path == NULL) { if (path == NULL) {
path = copy_xcode_path_for(CFSTR("Platforms/iPhoneOS.platform/DeviceSupport"), CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ (%@)"), version, build)); path = copy_xcode_path_for(deviceClassPath_platform, CFStringCreateWithFormat(NULL, NULL, CFSTR("%@\\ \\(%@\\)"), version, build));
} }
if (path == NULL) { if (path == NULL) {
path = copy_xcode_path_for(CFSTR("Platforms/iPhoneOS.platform/DeviceSupport"), CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ (*)"), version)); path = copy_xcode_path_for(deviceClassPath_platform, CFStringCreateWithFormat(NULL, NULL, CFSTR("%@\\ \\(*\\)"), version));
} }
if (path == NULL) { if (path == NULL) {
path = copy_xcode_path_for(CFSTR("Platforms/iPhoneOS.platform/DeviceSupport"), version); path = copy_xcode_path_for(deviceClassPath_platform, version);
} }
if (path == NULL) { if (path == NULL) {
path = copy_xcode_path_for(CFSTR("Platforms/iPhoneOS.platform/DeviceSupport/Latest"), CFSTR("")); path = copy_xcode_path_for(CFStringCreateWithFormat(NULL, NULL, CFSTR("%@%@"), deviceClassPath_platform, CFSTR("/Latest")), CFSTR(""));
} }
CFRelease(version); CFRelease(version);
if (path != NULL) { if (path != NULL) {
@@ -474,7 +494,7 @@ CFStringRef copy_device_support_path(AMDeviceRef device) {
CFRelease(version_parts); CFRelease(version_parts);
CFRelease(build); CFRelease(build);
CFRelease(deviceClass);
if (path == NULL) 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!");
@@ -484,25 +504,40 @@ CFStringRef copy_device_support_path(AMDeviceRef device) {
CFStringRef copy_developer_disk_image_path(AMDeviceRef device) { CFStringRef copy_developer_disk_image_path(AMDeviceRef device) {
CFStringRef version = NULL; CFStringRef version = NULL;
CFStringRef build = AMDeviceCopyValue(device, 0, CFSTR("BuildVersion")); CFStringRef build = AMDeviceCopyValue(device, 0, CFSTR("BuildVersion"));
CFStringRef deviceClass = AMDeviceCopyValue(device, 0, CFSTR("DeviceClass"));
CFStringRef path = NULL; CFStringRef path = NULL;
CFMutableArrayRef version_parts = get_device_product_version_parts(device); CFMutableArrayRef version_parts = get_device_product_version_parts(device);
NSLogVerbose(@"Device Class: %@", deviceClass);
NSLogVerbose(@"build: %@", build);
CFStringRef deviceClassPath_platform;
CFStringRef deviceClassPath_alt;
if (CFStringCompare(CFSTR("AppleTV"), deviceClass, 0) == kCFCompareEqualTo) {
deviceClassPath_platform = CFSTR("Platforms/AppleTVOS.platform/DeviceSupport");
deviceClassPath_alt = CFSTR("tvOS\\ DeviceSupport");
} else {
deviceClassPath_platform = CFSTR("Platforms/iPhoneOS.platform/DeviceSupport");
deviceClassPath_alt = CFSTR("iOS\\ DeviceSupport");
}
// path = getPathForTVOS(device);
while (CFArrayGetCount(version_parts) > 0) { while (CFArrayGetCount(version_parts) > 0) {
version = CFStringCreateByCombiningStrings(NULL, version_parts, CFSTR(".")); version = CFStringCreateByCombiningStrings(NULL, version_parts, CFSTR("."));
if (path == NULL) { NSLogVerbose(@"version: %@", version);
path = copy_xcode_path_for(CFSTR("iOS DeviceSupport"), CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ (%@)/DeveloperDiskImage.dmg"), version, build));
if (path == NULL) {
path = copy_xcode_path_for(CFStringCreateWithFormat(NULL, NULL, CFSTR("%@/%@\\ \\(%@\\)"), deviceClassPath_alt, version, build), CFSTR("DeveloperDiskImage.dmg"));
} }
if (path == NULL) { if (path == NULL) {
path = copy_xcode_path_for(CFSTR("Platforms/iPhoneOS.platform/DeviceSupport"), CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ (%@)/DeveloperDiskImage.dmg"), version, build)); path = copy_xcode_path_for(deviceClassPath_platform, CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ (%@)/DeveloperDiskImage.dmg"), version, build));
}
if (path == NULL) {
path = copy_xcode_path_for(CFSTR("Platforms/iPhoneOS.platform/DeviceSupport"), CFStringCreateWithFormat(NULL, NULL, CFSTR("*/%@ (*)/DeveloperDiskImage.dmg"), version));
} }
if (path == NULL) { if (path == NULL) {
path = copy_xcode_path_for(CFSTR("Platforms/iPhoneOS.platform/DeviceSupport"), CFStringCreateWithFormat(NULL, NULL, CFSTR("%@/DeveloperDiskImage.dmg"), version)); path = copy_xcode_path_for(CFStringCreateWithFormat(NULL, NULL, CFSTR("%@/%@\\ \\(*\\)"), deviceClassPath_platform, version), CFSTR("DeveloperDiskImage.dmg"));
} }
if (path == NULL) { if (path == NULL) {
path = copy_xcode_path_for(CFSTR("Platforms/iPhoneOS.platform/DeviceSupport/Latest"), CFSTR("DeveloperDiskImage.dmg")); path = copy_xcode_path_for(deviceClassPath_platform, CFStringCreateWithFormat(NULL, NULL, CFSTR("%@/DeveloperDiskImage.dmg"), version));
}
if (path == NULL) {
path = copy_xcode_path_for(CFStringCreateWithFormat(NULL, NULL, CFSTR("%@/Latest"), deviceClassPath_platform), CFSTR("/DeveloperDiskImage.dmg"));
} }
CFRelease(version); CFRelease(version);
if (path != NULL) { if (path != NULL) {
@@ -513,6 +548,7 @@ CFStringRef copy_developer_disk_image_path(AMDeviceRef device) {
CFRelease(version_parts); CFRelease(version_parts);
CFRelease(build); CFRelease(build);
CFRelease(deviceClass);
if (path == NULL) 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!");
@@ -536,9 +572,9 @@ void mount_developer_image(AMDeviceRef device) {
CFStringRef image_path = copy_developer_disk_image_path(device); CFStringRef image_path = copy_developer_disk_image_path(device);
CFStringRef sig_path = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@.signature"), image_path); CFStringRef sig_path = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@.signature"), image_path);
NSLogVerbose(@"Device support path: %@", ds_path); NSLogVerbose(@"Device support path: %@", ds_path);
NSLogVerbose(@"Developer disk image: %@", image_path); NSLogVerbose(@"Developer disk image: %@", image_path);
CFRelease(ds_path); CFRelease(ds_path);
FILE* sig = fopen(CFStringGetCStringPtr(sig_path, kCFStringEncodingMacRoman), "rb"); FILE* sig = fopen(CFStringGetCStringPtr(sig_path, kCFStringEncodingMacRoman), "rb");
void *sig_buf = malloc(128); void *sig_buf = malloc(128);
@@ -599,7 +635,7 @@ CFURLRef copy_device_app_url(AMDeviceRef device, CFStringRef identifier) {
CFDictionaryRef result = nil; CFDictionaryRef result = nil;
NSArray *a = [NSArray arrayWithObjects: NSArray *a = [NSArray arrayWithObjects:
@"CFBundleIdentifier", // absolute must @"CFBundleIdentifier", // absolute must
@"ApplicationDSID", @"ApplicationDSID",
@"ApplicationType", @"ApplicationType",
@"CFBundleExecutable", @"CFBundleExecutable",
@@ -624,7 +660,7 @@ CFURLRef copy_device_app_url(AMDeviceRef device, CFStringRef identifier) {
nil]; nil];
NSDictionary *optionsDict = [NSDictionary dictionaryWithObject:a forKey:@"ReturnAttributes"]; NSDictionary *optionsDict = [NSDictionary dictionaryWithObject:a forKey:@"ReturnAttributes"];
CFDictionaryRef options = (CFDictionaryRef)optionsDict; CFDictionaryRef options = (CFDictionaryRef)optionsDict;
check_error(AMDeviceLookupApplications(device, options, &result)); check_error(AMDeviceLookupApplications(device, options, &result));
@@ -643,9 +679,9 @@ CFStringRef copy_disk_app_identifier(CFURLRef disk_app_url) {
CFURLRef plist_url = CFURLCreateCopyAppendingPathComponent(NULL, disk_app_url, CFSTR("Info.plist"), false); CFURLRef plist_url = CFURLCreateCopyAppendingPathComponent(NULL, disk_app_url, CFSTR("Info.plist"), false);
CFReadStreamRef plist_stream = CFReadStreamCreateWithFile(NULL, plist_url); CFReadStreamRef plist_stream = CFReadStreamCreateWithFile(NULL, plist_url);
if (!CFReadStreamOpen(plist_stream)) { if (!CFReadStreamOpen(plist_stream)) {
on_error(@"Cannot read Info.plist file: %@", plist_url); on_error(@"Cannot read Info.plist file: %@", plist_url);
} }
CFPropertyListRef plist = CFPropertyListCreateWithStream(NULL, plist_stream, 0, kCFPropertyListImmutable, NULL, NULL); CFPropertyListRef plist = CFPropertyListCreateWithStream(NULL, plist_stream, 0, kCFPropertyListImmutable, NULL, NULL);
CFStringRef bundle_identifier = CFRetain(CFDictionaryGetValue(plist, CFSTR("CFBundleIdentifier"))); CFStringRef bundle_identifier = CFRetain(CFDictionaryGetValue(plist, CFSTR("CFBundleIdentifier")));
CFReadStreamClose(plist_stream); CFReadStreamClose(plist_stream);
@@ -722,14 +758,14 @@ void write_lldb_prep_cmds(AMDeviceRef device, CFURLRef disk_app_url) {
CFStringFindAndReplace(cmds, CFSTR("{disk_container}"), disk_container_path, range, 0); CFStringFindAndReplace(cmds, CFSTR("{disk_container}"), disk_container_path, range, 0);
NSString* python_file_path = [NSString stringWithFormat:@"/tmp/%@/fruitstrap_", tmpUUID]; NSString* python_file_path = [NSString stringWithFormat:@"/tmp/%@/fruitstrap_", tmpUUID];
mkdirp(python_file_path); mkdirp(python_file_path);
NSString* python_command = @"fruitstrap_"; NSString* python_command = @"fruitstrap_";
if(device_id != NULL) { if(device_id != NULL) {
python_file_path = [python_file_path stringByAppendingString:[NSString stringWithUTF8String:device_id]]; python_file_path = [python_file_path stringByAppendingString:[NSString stringWithUTF8String:device_id]];
python_command = [python_command stringByAppendingString:[NSString stringWithUTF8String:device_id]]; python_command = [python_command stringByAppendingString:[NSString stringWithUTF8String:device_id]];
} }
python_file_path = [python_file_path stringByAppendingString:@".py"]; python_file_path = [python_file_path stringByAppendingString:@".py"];
CFStringFindAndReplace(cmds, CFSTR("{python_command}"), (CFStringRef)python_command, range, 0); CFStringFindAndReplace(cmds, CFSTR("{python_command}"), (CFStringRef)python_command, range, 0);
range.length = CFStringGetLength(cmds); range.length = CFStringGetLength(cmds);
@@ -740,7 +776,7 @@ void write_lldb_prep_cmds(AMDeviceRef device, CFURLRef disk_app_url) {
NSString* prep_cmds_path = [NSString stringWithFormat:PREP_CMDS_PATH, tmpUUID]; NSString* prep_cmds_path = [NSString stringWithFormat:PREP_CMDS_PATH, tmpUUID];
if(device_id != NULL) { if(device_id != NULL) {
prep_cmds_path = [prep_cmds_path stringByAppendingString:[NSString stringWithUTF8String:device_id]]; prep_cmds_path = [prep_cmds_path stringByAppendingString:[NSString stringWithUTF8String:device_id]];
} }
FILE *out = fopen([prep_cmds_path UTF8String], "w"); FILE *out = fopen([prep_cmds_path UTF8String], "w");
fwrite(CFDataGetBytePtr(cmds_data), CFDataGetLength(cmds_data), 1, out); fwrite(CFDataGetBytePtr(cmds_data), CFDataGetLength(cmds_data), 1, out);
// Write additional commands based on mode we're running in // Write additional commands based on mode we're running in
@@ -993,12 +1029,12 @@ void launch_debugger(AMDeviceRef device, CFURLRef url) {
setup_dummy_pipe_on_stdin(pfd); setup_dummy_pipe_on_stdin(pfd);
NSString* lldb_shell; NSString* lldb_shell;
NSString* prep_cmds = [NSString stringWithFormat:PREP_CMDS_PATH, tmpUUID]; NSString* prep_cmds = [NSString stringWithFormat:PREP_CMDS_PATH, tmpUUID];
lldb_shell = [NSString stringWithFormat:LLDB_SHELL, prep_cmds]; lldb_shell = [NSString stringWithFormat:LLDB_SHELL, prep_cmds];
if(device_id != NULL) { if(device_id != NULL) {
lldb_shell = [lldb_shell stringByAppendingString: [NSString stringWithUTF8String:device_id]]; lldb_shell = [lldb_shell stringByAppendingString: [NSString stringWithUTF8String:device_id]];
} }
int status = system([lldb_shell UTF8String]); // launch lldb int status = system([lldb_shell UTF8String]); // launch lldb
if (status == -1) if (status == -1)
@@ -1034,10 +1070,10 @@ void launch_debugger_and_exit(AMDeviceRef device, CFURLRef url) {
NSString* prep_cmds = [NSString stringWithFormat:PREP_CMDS_PATH, tmpUUID]; NSString* prep_cmds = [NSString stringWithFormat:PREP_CMDS_PATH, tmpUUID];
NSString* lldb_shell = [NSString stringWithFormat:LLDB_SHELL, prep_cmds]; NSString* lldb_shell = [NSString stringWithFormat:LLDB_SHELL, prep_cmds];
if(device_id != NULL) { if(device_id != NULL) {
lldb_shell = [lldb_shell stringByAppendingString:[NSString stringWithUTF8String:device_id]]; lldb_shell = [lldb_shell stringByAppendingString:[NSString stringWithUTF8String:device_id]];
} }
int status = system([lldb_shell UTF8String]); // launch lldb int status = system([lldb_shell UTF8String]); // launch lldb
if (status == -1) if (status == -1)
@@ -1122,15 +1158,15 @@ void read_dir(service_conn_t afcFd, afc_connection* afc_conn_p, const char* dir,
} }
} }
AFCKeyValueClose(afc_dict_p); AFCKeyValueClose(afc_dict_p);
if (not_dir) {
NSLogOut(@"%@", [NSString stringWithUTF8String:dir]);
} else {
NSLogOut(@"%@/", [NSString stringWithUTF8String:dir]);
}
if (not_dir) { if (not_dir) {
if (callback) (*callback)(afc_conn_p, dir, not_dir); NSLogOut(@"%@", [NSString stringWithUTF8String:dir]);
} else {
NSLogOut(@"%@/", [NSString stringWithUTF8String:dir]);
}
if (not_dir) {
if (callback) (*callback)(afc_conn_p, dir, not_dir);
return; return;
} }
@@ -1192,9 +1228,9 @@ service_conn_t start_house_arrest_service(AMDeviceRef device) {
return houseFd; return houseFd;
} }
char* get_filename_from_path(char* path) char const* get_filename_from_path(char const* path)
{ {
char *ptr = path + strlen(path); char const*ptr = path + strlen(path);
while (ptr > path) while (ptr > path)
{ {
if (*ptr == '/') if (*ptr == '/')
@@ -1208,7 +1244,7 @@ char* get_filename_from_path(char* path)
return ptr+1; return ptr+1;
} }
void* read_file_to_memory(char * path, size_t* file_size) void* read_file_to_memory(char const * path, size_t* file_size)
{ {
struct stat buf; struct stat buf;
int err = stat(path, &buf); int err = stat(path, &buf);
@@ -1266,7 +1302,7 @@ int app_exists(AMDeviceRef device)
check_error(AMDeviceStopSession(device)); check_error(AMDeviceStopSession(device));
check_error(AMDeviceDisconnect(device)); check_error(AMDeviceDisconnect(device));
if (appExists) if (appExists)
return 0; return 0;
return -1; return -1;
} }
@@ -1276,13 +1312,13 @@ void list_bundle_id(AMDeviceRef device)
assert(AMDeviceIsPaired(device)); assert(AMDeviceIsPaired(device));
check_error(AMDeviceValidatePairing(device)); check_error(AMDeviceValidatePairing(device));
check_error(AMDeviceStartSession(device)); check_error(AMDeviceStartSession(device));
NSArray *a = [NSArray arrayWithObjects:@"CFBundleIdentifier", nil]; NSArray *a = [NSArray arrayWithObjects:@"CFBundleIdentifier", nil];
NSDictionary *optionsDict = [NSDictionary dictionaryWithObject:a forKey:@"ReturnAttributes"]; NSDictionary *optionsDict = [NSDictionary dictionaryWithObject:a forKey:@"ReturnAttributes"];
CFDictionaryRef options = (CFDictionaryRef)optionsDict; CFDictionaryRef options = (CFDictionaryRef)optionsDict;
CFDictionaryRef result = nil; CFDictionaryRef result = nil;
check_error(AMDeviceLookupApplications(device, options, &result)); check_error(AMDeviceLookupApplications(device, options, &result));
CFIndex count; CFIndex count;
count = CFDictionaryGetCount(result); count = CFDictionaryGetCount(result);
const void *keys[count]; const void *keys[count];
@@ -1290,7 +1326,7 @@ void list_bundle_id(AMDeviceRef device)
for(int i = 0; i < count; ++i) { for(int i = 0; i < count; ++i) {
NSLogOut(@"%@", (CFStringRef)keys[i]); NSLogOut(@"%@", (CFStringRef)keys[i]);
} }
check_error(AMDeviceStopSession(device)); check_error(AMDeviceStopSession(device));
check_error(AMDeviceDisconnect(device)); check_error(AMDeviceDisconnect(device));
} }
@@ -1304,35 +1340,35 @@ void copy_file_callback(afc_connection* afc_conn_p, const char *name,int file)
if (*local_name=='\0') return; if (*local_name=='\0') return;
if (file) { if (file) {
afc_file_ref fref; afc_file_ref fref;
int err = AFCFileRefOpen(afc_conn_p,name,1,&fref); int err = AFCFileRefOpen(afc_conn_p,name,1,&fref);
if (err) { if (err) {
fprintf(stderr,"AFCFileRefOpen(\"%s\") failed: %d\n",name,err); fprintf(stderr,"AFCFileRefOpen(\"%s\") failed: %d\n",name,err);
return; return;
} }
FILE *fp = fopen(local_name,"w"); FILE *fp = fopen(local_name,"w");
if (fp==NULL) { if (fp==NULL) {
fprintf(stderr,"fopen(\"%s\",\"w\") failer: %s\n",local_name,strerror(errno)); fprintf(stderr,"fopen(\"%s\",\"w\") failer: %s\n",local_name,strerror(errno));
AFCFileRefClose(afc_conn_p,fref); AFCFileRefClose(afc_conn_p,fref);
return; return;
} }
char buf[4096]; char buf[4096];
size_t sz=sizeof(buf); size_t sz=sizeof(buf);
while (AFCFileRefRead(afc_conn_p,fref,buf,&sz)==0 && sz) { while (AFCFileRefRead(afc_conn_p,fref,buf,&sz)==0 && sz) {
fwrite(buf,sz,1,fp); fwrite(buf,sz,1,fp);
sz = sizeof(buf); sz = sizeof(buf);
} }
AFCFileRefClose(afc_conn_p,fref); AFCFileRefClose(afc_conn_p,fref);
fclose(fp); fclose(fp);
} else { } else {
if (mkdir(local_name,0777) && errno!=EEXIST) if (mkdir(local_name,0777) && errno!=EEXIST)
fprintf(stderr,"mkdir(\"%s\") failed: %s\n",local_name,strerror(errno)); fprintf(stderr,"mkdir(\"%s\") failed: %s\n",local_name,strerror(errno));
} }
} }
@@ -1341,29 +1377,29 @@ void download_tree(AMDeviceRef device)
service_conn_t houseFd = start_house_arrest_service(device); service_conn_t houseFd = start_house_arrest_service(device);
afc_connection* afc_conn_p = NULL; afc_connection* afc_conn_p = NULL;
char *dirname = NULL; char *dirname = NULL;
list_root = list_root? list_root : "/"; list_root = list_root? list_root : "/";
target_filename = target_filename? target_filename : "."; target_filename = target_filename? target_filename : ".";
NSString* targetPath = [NSString pathWithComponents:@[ @(target_filename), @(list_root)] ]; NSString* targetPath = [NSString pathWithComponents:@[ @(target_filename), @(list_root)] ];
mkdirp([targetPath stringByDeletingLastPathComponent]); mkdirp([targetPath stringByDeletingLastPathComponent]);
if (AFCConnectionOpen(houseFd, 0, &afc_conn_p) == 0) do { if (AFCConnectionOpen(houseFd, 0, &afc_conn_p) == 0) do {
if (target_filename) { if (target_filename) {
dirname = strdup(target_filename); dirname = strdup(target_filename);
mkdirp(@(dirname)); mkdirp(@(dirname));
if (mkdir(dirname,0777) && errno!=EEXIST) { if (mkdir(dirname,0777) && errno!=EEXIST) {
fprintf(stderr,"mkdir(\"%s\") failed: %s\n",dirname,strerror(errno)); fprintf(stderr,"mkdir(\"%s\") failed: %s\n",dirname,strerror(errno));
break; break;
} }
if (chdir(dirname)) { if (chdir(dirname)) {
fprintf(stderr,"chdir(\"%s\") failed: %s\n",dirname,strerror(errno)); fprintf(stderr,"chdir(\"%s\") failed: %s\n",dirname,strerror(errno));
break; break;
} }
} }
read_dir(houseFd, afc_conn_p, list_root, copy_file_callback); read_dir(houseFd, afc_conn_p, list_root, copy_file_callback);
} while(0); } while(0);
@@ -1371,10 +1407,12 @@ void download_tree(AMDeviceRef device)
if (afc_conn_p) AFCConnectionClose(afc_conn_p); if (afc_conn_p) AFCConnectionClose(afc_conn_p);
} }
void upload_file(AMDeviceRef device) { void upload_dir(AMDeviceRef device, afc_connection* afc_conn_p, NSString* source, NSString* destination);
service_conn_t houseFd = start_house_arrest_service(device); void upload_single_file(AMDeviceRef device, afc_connection* afc_conn_p, NSString* sourcePath, NSString* destinationPath);
afc_file_ref file_ref; void upload_file(AMDeviceRef device)
{
service_conn_t houseFd = start_house_arrest_service(device);
afc_connection afc_conn; afc_connection afc_conn;
afc_connection* afc_conn_p = &afc_conn; afc_connection* afc_conn_p = &afc_conn;
@@ -1387,44 +1425,82 @@ void upload_file(AMDeviceRef device) {
target_filename = get_filename_from_path(upload_pathname); target_filename = get_filename_from_path(upload_pathname);
} }
NSString* sourcePath = [NSString stringWithUTF8String: upload_pathname];
NSString* destinationPath = [NSString stringWithUTF8String: target_filename];
BOOL isDir;
bool exists = [[NSFileManager defaultManager] fileExistsAtPath: sourcePath isDirectory: &isDir];
if (!exists)
{
on_error(@"Could not find file: %s", upload_pathname);
}
else if (isDir)
{
upload_dir(device, afc_conn_p, sourcePath, destinationPath);
}
else
{
upload_single_file(device, afc_conn_p, sourcePath, destinationPath);
}
assert(AFCConnectionClose(afc_conn_p) == 0);
}
void upload_single_file(AMDeviceRef device, afc_connection* afc_conn_p, NSString* sourcePath, NSString* destinationPath) {
afc_file_ref file_ref;
// read_dir(houseFd, NULL, "/", NULL);
size_t file_size; size_t file_size;
void* file_content = read_file_to_memory(upload_pathname, &file_size); void* file_content = read_file_to_memory([sourcePath fileSystemRepresentation], &file_size);
if (!file_content) if (!file_content)
{ {
on_error(@"Could not open file: %@", [NSString stringWithUTF8String:upload_pathname]); on_error(@"Could not open file: %@", sourcePath);
} }
// Make sure the directory was created // Make sure the directory was created
{ {
char *dirpath = strdup(target_filename); NSString *dirpath = [destinationPath stringByDeletingLastPathComponent];
char *c = dirpath, *lastSlash = dirpath; check_error(AFCDirectoryCreate(afc_conn_p, [dirpath fileSystemRepresentation]));
while(*c) {
if(*c == '/') {
lastSlash = c;
}
c++;
}
*lastSlash = '\0';
check_error(AFCDirectoryCreate(afc_conn_p, dirpath));
} }
int ret = AFCFileRefOpen(afc_conn_p, target_filename, 3, &file_ref); int ret = AFCFileRefOpen(afc_conn_p, [destinationPath fileSystemRepresentation], 3, &file_ref);
if (ret == 0x000a) { if (ret == 0x000a) {
on_error(@"Cannot write to %@. Permission error.", [NSString stringWithUTF8String:target_filename]); on_error(@"Cannot write to %@. Permission error.", destinationPath);
} }
if (ret == 0x0009) { if (ret == 0x0009) {
on_error(@"Target %@ is a directory.", [NSString stringWithUTF8String:target_filename]); on_error(@"Target %@ is a directory.", destinationPath);
} }
assert(ret == 0); assert(ret == 0);
assert(AFCFileRefWrite(afc_conn_p, file_ref, file_content, file_size) == 0); assert(AFCFileRefWrite(afc_conn_p, file_ref, file_content, file_size) == 0);
assert(AFCFileRefClose(afc_conn_p, file_ref) == 0); assert(AFCFileRefClose(afc_conn_p, file_ref) == 0);
assert(AFCConnectionClose(afc_conn_p) == 0);
free(file_content); free(file_content);
} }
void upload_dir(AMDeviceRef device, afc_connection* afc_conn_p, NSString* source, NSString* destination)
{
check_error(AFCDirectoryCreate(afc_conn_p, [destination fileSystemRepresentation]));
destination = [destination copy];
for (NSString* item in [[NSFileManager defaultManager] contentsOfDirectoryAtPath: source error: nil])
{
NSString* sourcePath = [source stringByAppendingPathComponent: item];
NSString* destinationPath = [destination stringByAppendingPathComponent: item];
BOOL isDir;
[[NSFileManager defaultManager] fileExistsAtPath: sourcePath isDirectory: &isDir];
if (isDir)
{
upload_dir(device, afc_conn_p, sourcePath, destinationPath);
}
else
{
upload_single_file(device, afc_conn_p, sourcePath, destinationPath);
}
}
}
void make_directory(AMDeviceRef device) { void make_directory(AMDeviceRef device) {
service_conn_t houseFd = start_house_arrest_service(device); service_conn_t houseFd = start_house_arrest_service(device);
@@ -1482,12 +1558,12 @@ void uninstall_app(AMDeviceRef device) {
} }
void handle_device(AMDeviceRef device) { void handle_device(AMDeviceRef device) {
NSLogVerbose(@"Already found device? %d", found_device); NSLogVerbose(@"Already found device? %d", found_device);
CFStringRef found_device_id = AMDeviceCopyDeviceIdentifier(device), CFStringRef found_device_id = AMDeviceCopyDeviceIdentifier(device),
device_full_name = get_device_full_name(device), device_full_name = get_device_full_name(device),
device_interface_name = get_device_interface_name(device); device_interface_name = get_device_interface_name(device);
if (detect_only) { if (detect_only) {
NSLogOut(@"[....] Found %@ connected through %@.", device_full_name, device_interface_name); NSLogOut(@"[....] Found %@ connected through %@.", device_full_name, device_interface_name);
found_device = true; found_device = true;
@@ -1515,7 +1591,7 @@ void handle_device(AMDeviceRef device) {
} else if (strcmp("upload", command) == 0) { } else if (strcmp("upload", command) == 0) {
upload_file(device); upload_file(device);
} else if (strcmp("download", command) == 0) { } else if (strcmp("download", command) == 0) {
download_tree(device); download_tree(device);
} else if (strcmp("mkdir", command) == 0) { } else if (strcmp("mkdir", command) == 0) {
make_directory(device); make_directory(device);
} else if (strcmp("rm", command) == 0) { } else if (strcmp("rm", command) == 0) {
@@ -1636,17 +1712,17 @@ void device_callback(struct am_device_notification_callback_info *info, void *ar
switch (info->msg) { switch (info->msg) {
case ADNCI_MSG_CONNECTED: case ADNCI_MSG_CONNECTED:
if(device_id != NULL || !debug || AMDeviceGetInterfaceType(info->dev) != 2) { if(device_id != NULL || !debug || AMDeviceGetInterfaceType(info->dev) != 2) {
if (no_wifi && AMDeviceGetInterfaceType(info->dev) == 2) if (no_wifi && AMDeviceGetInterfaceType(info->dev) == 2)
{ {
NSLogVerbose(@"Skipping wifi device (type: %d)", AMDeviceGetInterfaceType(info->dev)); NSLogVerbose(@"Skipping wifi device (type: %d)", AMDeviceGetInterfaceType(info->dev));
} }
else else
{ {
NSLogVerbose(@"Handling device type: %d", AMDeviceGetInterfaceType(info->dev)); NSLogVerbose(@"Handling device type: %d", AMDeviceGetInterfaceType(info->dev));
handle_device(info->dev); handle_device(info->dev);
} }
} else if(best_device_match == NULL) { } else if(best_device_match == NULL) {
NSLogVerbose(@"Best device match: %d", AMDeviceGetInterfaceType(info->dev)); NSLogVerbose(@"Best device match: %d", AMDeviceGetInterfaceType(info->dev));
best_device_match = info->dev; best_device_match = info->dev;
CFRetain(best_device_match); CFRetain(best_device_match);
} }
@@ -1658,7 +1734,7 @@ void device_callback(struct am_device_notification_callback_info *info, void *ar
void timeout_callback(CFRunLoopTimerRef timer, void *info) { void timeout_callback(CFRunLoopTimerRef timer, void *info) {
if ((!found_device) && (!detect_only)) { if ((!found_device) && (!detect_only)) {
if(best_device_match != NULL) { if(best_device_match != NULL) {
NSLogVerbose(@"Handling best device match."); NSLogVerbose(@"Handling best device match.");
handle_device(best_device_match); handle_device(best_device_match);
CFRelease(best_device_match); CFRelease(best_device_match);
@@ -1681,8 +1757,8 @@ void timeout_callback(CFRunLoopTimerRef timer, void *info) {
int mypid = getpid(); int mypid = getpid();
if ((parent != 0) && (parent == mypid) && (child != 0)) if ((parent != 0) && (parent == mypid) && (child != 0))
{ {
NSLogVerbose(@"Timeout. Killing child (%d) tree.", child); NSLogVerbose(@"Timeout. Killing child (%d) tree.", child);
kill_ptree(child, SIGHUP); kill_ptree(child, SIGHUP);
} }
} }
exit(0); exit(0);
@@ -1729,12 +1805,12 @@ void show_version() {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
// create a UUID for tmp purposes // create a UUID for tmp purposes
CFUUIDRef uuid = CFUUIDCreate(NULL); CFUUIDRef uuid = CFUUIDCreate(NULL);
CFStringRef str = CFUUIDCreateString(NULL, uuid); CFStringRef str = CFUUIDCreateString(NULL, uuid);
CFRelease(uuid); CFRelease(uuid);
tmpUUID = [(NSString*)str autorelease]; tmpUUID = [(NSString*)str autorelease];
static struct option longopts[] = { static struct option longopts[] = {
{ "debug", no_argument, NULL, 'd' }, { "debug", no_argument, NULL, 'd' },
{ "id", required_argument, NULL, 'i' }, { "id", required_argument, NULL, 'i' },

View File

@@ -1,86 +0,0 @@
"# AUTO-GENERATED - DO NOT MODIFY\n"
"import lldb\n"
"import os\n"
"import sys\n"
"import shlex\n"
"\n"
"def connect_command(debugger, command, result, internal_dict):\n"
" # These two are passed in by the script which loads us\n"
" connect_url = internal_dict['fruitstrap_connect_url']\n"
" error = lldb.SBError()\n"
"\n"
" process = lldb.target.ConnectRemote(lldb.target.GetDebugger().GetListener(), connect_url, None, error)\n"
"\n"
" # Wait for connection to succeed\n"
" listener = lldb.target.GetDebugger().GetListener()\n"
" listener.StartListeningForEvents(process.GetBroadcaster(), lldb.SBProcess.eBroadcastBitStateChanged)\n"
" events = []\n"
" state = (process.GetState() or lldb.eStateInvalid)\n"
" while state != lldb.eStateConnected:\n"
" event = lldb.SBEvent()\n"
" if listener.WaitForEvent(1, event):\n"
" state = process.GetStateFromEvent(event)\n"
" events.append(event)\n"
" else:\n"
" state = lldb.eStateInvalid\n"
"\n"
" # Add events back to queue, otherwise lldb freezes\n"
" for event in events:\n"
" listener.AddEvent(event)\n"
"\n"
"def run_command(debugger, command, result, internal_dict):\n"
" device_app = internal_dict['fruitstrap_device_app']\n"
" args = command.split('--',1)\n"
" error = lldb.SBError()\n"
" lldb.target.modules[0].SetPlatformFileSpec(lldb.SBFileSpec(device_app))\n"
" lldb.target.Launch(lldb.SBLaunchInfo(shlex.split(args[1] and args[1] or '{args}')), error)\n"
" lockedstr = ': Locked'\n"
" if lockedstr in str(error):\n"
" print('\\nDevice Locked\\n')\n"
" os._exit(254)\n"
" else:\n"
" print(str(error))\n"
"\n"
"def safequit_command(debugger, command, result, internal_dict):\n"
" process = lldb.target.process\n"
" listener = debugger.GetListener()\n"
" listener.StartListeningForEvents(process.GetBroadcaster(), lldb.SBProcess.eBroadcastBitStateChanged | lldb.SBProcess.eBroadcastBitSTDOUT | lldb.SBProcess.eBroadcastBitSTDERR)\n"
" event = lldb.SBEvent()\n"
" while True:\n"
" if listener.WaitForEvent(1, event) and lldb.SBProcess.EventIsProcessEvent(event):\n"
" state = lldb.SBProcess.GetStateFromEvent(event)\n"
" else:\n"
" state = process.GetState()\n"
"\n"
" if state == lldb.eStateRunning:\n"
" process.Detach()\n"
" os._exit(0)\n"
" elif state > lldb.eStateRunning:\n"
" os._exit(state)\n"
"\n"
"def autoexit_command(debugger, command, result, internal_dict):\n"
" process = lldb.target.process\n"
" listener = debugger.GetListener()\n"
" listener.StartListeningForEvents(process.GetBroadcaster(), lldb.SBProcess.eBroadcastBitStateChanged | lldb.SBProcess.eBroadcastBitSTDOUT | lldb.SBProcess.eBroadcastBitSTDERR)\n"
" event = lldb.SBEvent()\n"
" while True:\n"
" if listener.WaitForEvent(1, event) and lldb.SBProcess.EventIsProcessEvent(event):\n"
" state = lldb.SBProcess.GetStateFromEvent(event)\n"
" else:\n"
" state = process.GetState()\n"
"\n"
" if state == lldb.eStateExited:\n"
" os._exit(process.GetExitStatus())\n"
" elif state == lldb.eStateStopped:\n"
" debugger.HandleCommand('bt')\n"
" os._exit({exitcode_app_crash})\n"
"\n"
" stdout = process.GetSTDOUT(1024)\n"
" while stdout:\n"
" sys.stdout.write(stdout)\n"
" stdout = process.GetSTDOUT(1024)\n"
"\n"
" stderr = process.GetSTDERR(1024)\n"
" while stderr:\n"
" sys.stdout.write(stderr)\n"
" stderr = process.GetSTDERR(1024)\n"

View File

@@ -1 +1 @@
"1.8.4" "1.9.0"

View File

@@ -36,6 +36,17 @@ xcode_version.on('close', function (code) {
if (ver < XCODEBUILD_MIN_VERSION) { if (ver < XCODEBUILD_MIN_VERSION) {
console.log(util.format('%s : %s. (you have version %s)', TOOL, XCODEBUILD_NOT_FOUND_MESSAGE, ver)); console.log(util.format('%s : %s. (you have version %s)', TOOL, XCODEBUILD_NOT_FOUND_MESSAGE, ver));
} }
if (os.release() >= '15.0.0') { // print the El Capitan warning
console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
console.log('!!!! WARNING: You are on OS X 10.11 El Capitan, you may need to add the');
console.log('!!!! WARNING: `--unsafe-perm=true` flag when running `npm install`');
console.log('!!!! WARNING: or else it will fail.');
console.log('!!!! WARNING: link:');
console.log('!!!! WARNING: https://github.com/phonegap/ios-deploy#os-x-1011-el-capitan');
console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
}
} }
process.exit(code); process.exit(code);
}); });

View File

@@ -32,7 +32,12 @@ def run_command(debugger, command, result, internal_dict):
args = command.split('--',1) args = command.split('--',1)
error = lldb.SBError() error = lldb.SBError()
lldb.target.modules[0].SetPlatformFileSpec(lldb.SBFileSpec(device_app)) lldb.target.modules[0].SetPlatformFileSpec(lldb.SBFileSpec(device_app))
lldb.target.Launch(lldb.SBLaunchInfo(shlex.split(args[1] and args[1] or '{args}')), error) args_arr = []
if len(args) > 1:
args_arr = shlex.split(args[1])
else:
args_arr = shlex.split('{args}')
lldb.target.Launch(lldb.SBLaunchInfo(args_arr), error)
lockedstr = ': Locked' lockedstr = ': Locked'
if lockedstr in str(error): if lockedstr in str(error):
print('\\nDevice Locked\\n') print('\\nDevice Locked\\n')
@@ -42,20 +47,15 @@ def run_command(debugger, command, result, internal_dict):
def safequit_command(debugger, command, result, internal_dict): def safequit_command(debugger, command, result, internal_dict):
process = lldb.target.process process = lldb.target.process
listener = debugger.GetListener() state = process.GetState()
listener.StartListeningForEvents(process.GetBroadcaster(), lldb.SBProcess.eBroadcastBitStateChanged | lldb.SBProcess.eBroadcastBitSTDOUT | lldb.SBProcess.eBroadcastBitSTDERR) if state == lldb.eStateRunning:
event = lldb.SBEvent() process.Detach()
while True: os._exit(0)
if listener.WaitForEvent(1, event) and lldb.SBProcess.EventIsProcessEvent(event): elif state > lldb.eStateRunning:
state = lldb.SBProcess.GetStateFromEvent(event) os._exit(state)
else: else:
state = process.GetState() print('\\nApplication has not been launched\\n')
os._exit(1)
if state == lldb.eStateRunning:
process.Detach()
os._exit(0)
elif state > lldb.eStateRunning:
os._exit(state)
def autoexit_command(debugger, command, result, internal_dict): def autoexit_command(debugger, command, result, internal_dict):
process = lldb.target.process process = lldb.target.process