From 7d997b89c76153b85bf5c3f4a5dff49a115aa92a Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Thu, 16 Jul 2015 16:57:24 -0700 Subject: [PATCH 01/23] Removed buildbox shell script --- resources/buildbox/build.sh | 3 --- 1 file changed, 3 deletions(-) delete mode 100755 resources/buildbox/build.sh diff --git a/resources/buildbox/build.sh b/resources/buildbox/build.sh deleted file mode 100755 index aea6cbf..0000000 --- a/resources/buildbox/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -echo "$ make" -make \ No newline at end of file From bc1bb0d3200d06148cec8914f1522e7fe38c71c8 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Thu, 16 Jul 2015 17:26:48 -0700 Subject: [PATCH 02/23] Fixes #135 - convert Makefile to Xcode project --- Entitlements.plist | 8 - Info.plist | 24 -- ResourceRules.plist | 25 -- demo.c | 9 - ios-deploy-demo/main.m | 17 ++ ios-deploy.xcodeproj/project.pbxproj | 394 +++++++++++++++++++++++++++ MobileDevice.h => src/MobileDevice.h | 0 errors.h => src/errors.h | 0 ios-deploy.c => src/ios-deploy.c | 25 +- 9 files changed, 421 insertions(+), 81 deletions(-) delete mode 100644 Entitlements.plist delete mode 100644 Info.plist delete mode 100644 ResourceRules.plist delete mode 100644 demo.c create mode 100644 ios-deploy-demo/main.m create mode 100644 ios-deploy.xcodeproj/project.pbxproj rename MobileDevice.h => src/MobileDevice.h (100%) rename errors.h => src/errors.h (100%) rename ios-deploy.c => src/ios-deploy.c (99%) diff --git a/Entitlements.plist b/Entitlements.plist deleted file mode 100644 index 929c4e9..0000000 --- a/Entitlements.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - get-task-allow - - - \ No newline at end of file diff --git a/Info.plist b/Info.plist deleted file mode 100644 index c2ade14..0000000 --- a/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - CFBundleName - demo - CFBundleSupportedPlatforms - - iPhoneOS - - CFBundleExecutable - demo - CFBundleVersion - 1.0 - CFBundleIdentifier - demo - CFBundleResourceSpecification - ResourceRules.plist - LSRequiresIPhoneOS - - CFBundleDisplayName - demo - - \ No newline at end of file diff --git a/ResourceRules.plist b/ResourceRules.plist deleted file mode 100644 index e7ec329..0000000 --- a/ResourceRules.plist +++ /dev/null @@ -1,25 +0,0 @@ - - - - - rules - - .* - - Info.plist - - omit - - weight - 10 - - ResourceRules.plist - - omit - - weight - 100 - - - - diff --git a/demo.c b/demo.c deleted file mode 100644 index 583f43b..0000000 --- a/demo.c +++ /dev/null @@ -1,9 +0,0 @@ -#include - -int main(int argc, const char* argv[]) { - int i; - for (i = 0; i < argc; i++) { - printf("argv[%d] = %s\n", i, argv[i]); - } - return 0; -} diff --git a/ios-deploy-demo/main.m b/ios-deploy-demo/main.m new file mode 100644 index 0000000..c64512e --- /dev/null +++ b/ios-deploy-demo/main.m @@ -0,0 +1,17 @@ +// +// main.m +// ios-deploy-demo +// +// Created by shazron on 7/16/15. +// Copyright (c) 2015 PhoneGap. All rights reserved. +// + +#import + +int main(int argc, const char * argv[]) { + @autoreleasepool { + // insert code here... + NSLog(@"Hello, World!"); + } + return 0; +} diff --git a/ios-deploy.xcodeproj/project.pbxproj b/ios-deploy.xcodeproj/project.pbxproj new file mode 100644 index 0000000..63e2385 --- /dev/null +++ b/ios-deploy.xcodeproj/project.pbxproj @@ -0,0 +1,394 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 7E70899C1B587DE4004D23AA /* ios-deploy.c in Sources */ = {isa = PBXBuildFile; fileRef = 7E7089991B587DE4004D23AA /* ios-deploy.c */; settings = {COMPILER_FLAGS = "-x objective-c -fno-objc-arc"; }; }; + 7E70899E1B587F29004D23AA /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E70899D1B587F29004D23AA /* CoreFoundation.framework */; }; + 7E7089A01B58801E004D23AA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E70899F1B58801E004D23AA /* Foundation.framework */; }; + 7E7089B31B58826A004D23AA /* demo.c in Sources */ = {isa = PBXBuildFile; fileRef = 7E7089AF1B58826A004D23AA /* demo.c */; }; + 7E7089B41B5882C3004D23AA /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E70899D1B587F29004D23AA /* CoreFoundation.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 7E70898C1B587BF3004D23AA /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; + 7E7089A51B58825B004D23AA /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 7E70898E1B587BF3004D23AA /* ios-deploy */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "ios-deploy"; sourceTree = BUILT_PRODUCTS_DIR; }; + 7E7089991B587DE4004D23AA /* ios-deploy.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "ios-deploy.c"; path = "src/ios-deploy.c"; sourceTree = SOURCE_ROOT; }; + 7E70899A1B587DE4004D23AA /* errors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = errors.h; path = src/errors.h; sourceTree = SOURCE_ROOT; }; + 7E70899B1B587DE4004D23AA /* MobileDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MobileDevice.h; path = src/MobileDevice.h; sourceTree = SOURCE_ROOT; }; + 7E70899D1B587F29004D23AA /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; + 7E70899F1B58801E004D23AA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 7E7089A71B58825B004D23AA /* ios-deploy-demo */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "ios-deploy-demo"; sourceTree = BUILT_PRODUCTS_DIR; }; + 7E7089A91B58825B004D23AA /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 7E7089AF1B58826A004D23AA /* demo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = demo.c; sourceTree = ""; }; + 7E7089B01B58826A004D23AA /* Entitlements.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Entitlements.plist; sourceTree = ""; }; + 7E7089B11B58826A004D23AA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 7E7089B21B58826A004D23AA /* ResourceRules.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = ResourceRules.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 7E70898B1B587BF3004D23AA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 7E7089A01B58801E004D23AA /* Foundation.framework in Frameworks */, + 7E70899E1B587F29004D23AA /* CoreFoundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 7E7089A41B58825B004D23AA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 7E7089B41B5882C3004D23AA /* CoreFoundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 7E7089851B587BF3004D23AA = { + isa = PBXGroup; + children = ( + 7E7089AE1B58826A004D23AA /* demo */, + 7E7089901B587BF3004D23AA /* ios-deploy */, + 7E7089A81B58825B004D23AA /* ios-deploy-demo */, + 7E7089A21B588219004D23AA /* Frameworks */, + 7E70898F1B587BF3004D23AA /* Products */, + ); + sourceTree = ""; + }; + 7E70898F1B587BF3004D23AA /* Products */ = { + isa = PBXGroup; + children = ( + 7E70898E1B587BF3004D23AA /* ios-deploy */, + 7E7089A71B58825B004D23AA /* ios-deploy-demo */, + ); + name = Products; + sourceTree = ""; + }; + 7E7089901B587BF3004D23AA /* ios-deploy */ = { + isa = PBXGroup; + children = ( + 7E7089991B587DE4004D23AA /* ios-deploy.c */, + 7E70899A1B587DE4004D23AA /* errors.h */, + 7E70899B1B587DE4004D23AA /* MobileDevice.h */, + ); + path = "ios-deploy"; + sourceTree = ""; + }; + 7E7089A21B588219004D23AA /* Frameworks */ = { + isa = PBXGroup; + children = ( + 7E70899F1B58801E004D23AA /* Foundation.framework */, + 7E70899D1B587F29004D23AA /* CoreFoundation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 7E7089A81B58825B004D23AA /* ios-deploy-demo */ = { + isa = PBXGroup; + children = ( + 7E7089A91B58825B004D23AA /* main.m */, + ); + path = "ios-deploy-demo"; + sourceTree = ""; + }; + 7E7089AE1B58826A004D23AA /* demo */ = { + isa = PBXGroup; + children = ( + 7E7089AF1B58826A004D23AA /* demo.c */, + 7E7089B01B58826A004D23AA /* Entitlements.plist */, + 7E7089B11B58826A004D23AA /* Info.plist */, + 7E7089B21B58826A004D23AA /* ResourceRules.plist */, + ); + path = demo; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 7E70898D1B587BF3004D23AA /* ios-deploy */ = { + isa = PBXNativeTarget; + buildConfigurationList = 7E7089951B587BF3004D23AA /* Build configuration list for PBXNativeTarget "ios-deploy" */; + buildPhases = ( + 7E70898A1B587BF3004D23AA /* Sources */, + 7E70898B1B587BF3004D23AA /* Frameworks */, + 7E70898C1B587BF3004D23AA /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "ios-deploy"; + productName = "ios-deploy"; + productReference = 7E70898E1B587BF3004D23AA /* ios-deploy */; + productType = "com.apple.product-type.tool"; + }; + 7E7089A61B58825B004D23AA /* ios-deploy-demo */ = { + isa = PBXNativeTarget; + buildConfigurationList = 7E7089AB1B58825B004D23AA /* Build configuration list for PBXNativeTarget "ios-deploy-demo" */; + buildPhases = ( + 7E7089A31B58825B004D23AA /* Sources */, + 7E7089A41B58825B004D23AA /* Frameworks */, + 7E7089A51B58825B004D23AA /* CopyFiles */, + 7E7089B51B5882EC004D23AA /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "ios-deploy-demo"; + productName = "ios-deploy-demo"; + productReference = 7E7089A71B58825B004D23AA /* ios-deploy-demo */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 7E7089861B587BF3004D23AA /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0640; + ORGANIZATIONNAME = PhoneGap; + TargetAttributes = { + 7E70898D1B587BF3004D23AA = { + CreatedOnToolsVersion = 6.4; + }; + 7E7089A61B58825B004D23AA = { + CreatedOnToolsVersion = 6.4; + }; + }; + }; + buildConfigurationList = 7E7089891B587BF3004D23AA /* Build configuration list for PBXProject "ios-deploy" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 7E7089851B587BF3004D23AA; + productRefGroup = 7E70898F1B587BF3004D23AA /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 7E70898D1B587BF3004D23AA /* ios-deploy */, + 7E7089A61B58825B004D23AA /* ios-deploy-demo */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXShellScriptBuildPhase section */ + 7E7089B51B5882EC004D23AA /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "#mkdir -p demo.app\n#cp demo demo.app/\n#cp Info.plist ResourceRules.plist demo.app/\n#codesign -f -s \"iPhone Developer\" --entitlements Entitlements.plist demo.app"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 7E70898A1B587BF3004D23AA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 7E70899C1B587DE4004D23AA /* ios-deploy.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 7E7089A31B58825B004D23AA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 7E7089B31B58826A004D23AA /* demo.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 7E7089931B587BF3004D23AA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.8; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = ( + "-framework", + MobileDevice, + "-F/System/Library/PrivateFrameworks", + ); + SDKROOT = macosx; + }; + name = Debug; + }; + 7E7089941B587BF3004D23AA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.8; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ( + "-framework", + MobileDevice, + "-F/System/Library/PrivateFrameworks", + ); + SDKROOT = macosx; + }; + name = Release; + }; + 7E7089961B587BF3004D23AA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 7E7089971B587BF3004D23AA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + 7E7089AC1B58825B004D23AA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + MACOSX_DEPLOYMENT_TARGET = 10.8; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 7E7089AD1B58825B004D23AA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + MACOSX_DEPLOYMENT_TARGET = 10.8; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 7E7089891B587BF3004D23AA /* Build configuration list for PBXProject "ios-deploy" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 7E7089931B587BF3004D23AA /* Debug */, + 7E7089941B587BF3004D23AA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 7E7089951B587BF3004D23AA /* Build configuration list for PBXNativeTarget "ios-deploy" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 7E7089961B587BF3004D23AA /* Debug */, + 7E7089971B587BF3004D23AA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 7E7089AB1B58825B004D23AA /* Build configuration list for PBXNativeTarget "ios-deploy-demo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 7E7089AC1B58825B004D23AA /* Debug */, + 7E7089AD1B58825B004D23AA /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 7E7089861B587BF3004D23AA /* Project object */; +} diff --git a/MobileDevice.h b/src/MobileDevice.h similarity index 100% rename from MobileDevice.h rename to src/MobileDevice.h diff --git a/errors.h b/src/errors.h similarity index 100% rename from errors.h rename to src/errors.h diff --git a/ios-deploy.c b/src/ios-deploy.c similarity index 99% rename from ios-deploy.c rename to src/ios-deploy.c index 9966ccd..7a601e1 100644 --- a/ios-deploy.c +++ b/src/ios-deploy.c @@ -169,7 +169,7 @@ char *app_path = NULL; char *device_id = NULL; char *args = NULL; char *list_root = NULL; -int timeout = 0; +int _timeout = 0; int port = 0; // 0 means "dynamically assigned" CFStringRef last_path = NULL; service_conn_t gdbfd; @@ -315,7 +315,7 @@ const char *get_home() { CFStringRef copy_xcode_path_for(CFStringRef subPath, CFStringRef search) { CFStringRef xcodeDevPath = copy_xcode_dev_path(); - CFStringRef path; + CFStringRef path = NULL; bool found = false; const char* home = get_home(); CFRange slashLocation; @@ -846,7 +846,7 @@ int kill_ptree(pid_t root, int signum); void server_callback (CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, const void *data, void *info) { - int res; + ssize_t res; if (CFDataGetLength (data) == 0) { // close the socket on which we've got end-of-file, the server_socket. @@ -956,7 +956,7 @@ int kill_ptree(pid_t root, int signum) { return -1; } - kill_ptree_inner(root, signum, kp, len / sizeof(struct kinfo_proc)); + kill_ptree_inner(root, signum, kp, (int)(len / sizeof(struct kinfo_proc))); free(kp); return 0; @@ -1338,7 +1338,6 @@ void list_bundle_id(AMDeviceRef device) const void *keys[count]; CFDictionaryGetKeysAndValues(result, keys, NULL); for(int i = 0; i < count; ++i) { - CFStringRef test = (CFStringRef)keys[i]; NSLogOut(@"%@", (CFStringRef)keys[i]); } @@ -1485,8 +1484,6 @@ void upload_file(AMDeviceRef device) { void make_directory(AMDeviceRef device) { service_conn_t houseFd = start_house_arrest_service(device); - afc_file_ref file_ref; - afc_connection afc_conn; afc_connection* afc_conn_p = &afc_conn; AFCConnectionOpen(houseFd, 0, &afc_conn_p); @@ -1498,8 +1495,6 @@ void make_directory(AMDeviceRef device) { void remove_path(AMDeviceRef device) { service_conn_t houseFd = start_house_arrest_service(device); - afc_file_ref file_ref; - afc_connection afc_conn; afc_connection* afc_conn_p = &afc_conn; AFCConnectionOpen(houseFd, 0, &afc_conn_p); @@ -1833,7 +1828,7 @@ int main(int argc, char *argv[]) { verbose = 1; break; case 't': - timeout = atoi(optarg); + _timeout = atoi(optarg); break; case 'u': unbuffered = 1; @@ -1922,8 +1917,8 @@ int main(int argc, char *argv[]) { setbuf(stderr, NULL); } - if (detect_only && timeout == 0) { - timeout = 5; + if (detect_only && _timeout == 0) { + _timeout = 5; } if (app_path) { @@ -1933,11 +1928,11 @@ int main(int argc, char *argv[]) { } AMDSetLogLevel(5); // otherwise syslog gets flooded with crap - if (timeout > 0) + if (_timeout > 0) { - CFRunLoopTimerRef timer = CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent() + timeout, 0, 0, 0, timeout_callback, NULL); + CFRunLoopTimerRef timer = CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent() + _timeout, 0, 0, 0, timeout_callback, NULL); CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopCommonModes); - NSLogOut(@"[....] Waiting up to %d seconds for iOS device to be connected", timeout); + NSLogOut(@"[....] Waiting up to %d seconds for iOS device to be connected", _timeout); } else { From 99dba4e58c8f76bc9c1c7a9b00fb626feb2617dd Mon Sep 17 00:00:00 2001 From: Julius Trinkunas Date: Wed, 22 Jul 2015 18:16:31 +0300 Subject: [PATCH 03/23] Fixes #157 - Bad error formatting string in check_error() --- src/ios-deploy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ios-deploy.c b/src/ios-deploy.c index 7a601e1..779682f 100644 --- a/src/ios-deploy.c +++ b/src/ios-deploy.c @@ -193,7 +193,7 @@ const int exitcode_app_crash = 254; { \ 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 ? [NSString stringWithUTF8String:msg] : @"unknown."); \ + on_error(@"Error 0x%x: %@ " #call, err, msg ? [NSString stringWithUTF8String:msg] : @"unknown."); \ } \ } while (false); From d10562c501a33a9eedb451fadd96bc884e7457f7 Mon Sep 17 00:00:00 2001 From: Julius Trinkunas Date: Wed, 22 Jul 2015 18:19:02 +0300 Subject: [PATCH 04/23] Add text for 0xe8008019 error. --- src/errors.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/errors.h b/src/errors.h index 106ab28..4cdebec 100644 --- a/src/errors.h +++ b/src/errors.h @@ -168,7 +168,9 @@ static errorcode_to_id_t errorcode_to_id[] = { { 0xe800009b, "kAMDMCChallengeRequired" }, { 0xe800009c, "kAMDMissingBundleVersionError" }, + // Errors without id->string mapping. { 0xe8008015, "A valid provisioning profile for this executable was not found."}, + { 0xe8008019, "The application does not have a valid signature." }, }; const int errorcode_to_id_count = sizeof(errorcode_to_id) / sizeof(errorcode_to_id_t); From 4d58838ef11f164439c0fb515f95c4cca787abb1 Mon Sep 17 00:00:00 2001 From: Julius Trinkunas Date: Wed, 22 Jul 2015 18:33:51 +0300 Subject: [PATCH 05/23] Add text for 0xe800801c error. --- src/errors.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/errors.h b/src/errors.h index 4cdebec..b3b4815 100644 --- a/src/errors.h +++ b/src/errors.h @@ -171,6 +171,7 @@ static errorcode_to_id_t errorcode_to_id[] = { // Errors without id->string mapping. { 0xe8008015, "A valid provisioning profile for this executable was not found."}, { 0xe8008019, "The application does not have a valid signature." }, + { 0xe800801c, "No code signature found." }, }; const int errorcode_to_id_count = sizeof(errorcode_to_id) / sizeof(errorcode_to_id_t); From 093b4b3c9a0c2aa4cfcd2afb5f8453e3fa989b33 Mon Sep 17 00:00:00 2001 From: Julius Trinkunas Date: Tue, 28 Jul 2015 13:00:15 +0300 Subject: [PATCH 06/23] Add text for error 0xe8008018. --- src/errors.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/errors.h b/src/errors.h index b3b4815..6a3160a 100644 --- a/src/errors.h +++ b/src/errors.h @@ -169,7 +169,8 @@ static errorcode_to_id_t errorcode_to_id[] = { { 0xe800009c, "kAMDMissingBundleVersionError" }, // Errors without id->string mapping. - { 0xe8008015, "A valid provisioning profile for this executable was not found."}, + { 0xe8008015, "A valid provisioning profile for this executable was not found." }, + { 0xe8008018, "The identity used to sign the executable is no longer valid. Please verify that your device’s clock is properly set, and that your signing certificate is not expired." }, { 0xe8008019, "The application does not have a valid signature." }, { 0xe800801c, "No code signature found." }, }; From ed7c70aa593bec97dcd7bf71ab25fbabf724ce70 Mon Sep 17 00:00:00 2001 From: Julius Trinkunas Date: Mon, 10 Aug 2015 16:01:13 +0300 Subject: [PATCH 07/23] Add attribution for error code reverse engineering. --- LICENSE | 6 ++++++ src/errors.h | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index e8010a3..f8e017a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,2 +1,8 @@ ios-deploy is available under the provisions of the GNU General Public License, version 3 (or later), available here: http://www.gnu.org/licenses/gpl-3.0.html + + +Error codes used for error messages were taken from SDMMobileDevice framework, +originally reverse engineered by Sam Marshall. SDMMobileDevice is distributed +under BSD 3-Clause license and is available here: +https://github.com/samdmarshall/SDMMobileDevice diff --git a/src/errors.h b/src/errors.h index 6a3160a..616ec70 100644 --- a/src/errors.h +++ b/src/errors.h @@ -9,7 +9,8 @@ typedef struct error_id_to_message { const char* message; } error_id_to_message_t; -// Taken from https://github.com/samdmarshall/SDMMobileDevice/blob/master/Framework/MobileDevice/Error/SDMMD_Error.h +// Most error codes are taken from SDMMobileDevice framework, and were reverse engineered by Sam Marshall. +// https://github.com/samdmarshall/SDMMobileDevice/blob/master/Framework/MobileDevice/Error/SDMMD_Error.h static errorcode_to_id_t errorcode_to_id[] = { { 0xe8000001, "kAMDUndefinedError" }, { 0xe8000002, "kAMDBadHeaderError" }, From ca2e7a3c75c8e3912d7b7c9eb90f6a4d2e641213 Mon Sep 17 00:00:00 2001 From: Julius Trinkunas Date: Tue, 11 Aug 2015 13:28:04 +0300 Subject: [PATCH 08/23] Add attribution for error code reverse engineering. Second try. --- src/errors.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/errors.h b/src/errors.h index 616ec70..fe8f42f 100644 --- a/src/errors.h +++ b/src/errors.h @@ -9,8 +9,29 @@ typedef struct error_id_to_message { const char* message; } error_id_to_message_t; -// Most error codes are taken from SDMMobileDevice framework, and were reverse engineered by Sam Marshall. +// Parts of error code to localization id map is taken from SDMMobileDevice framework. Associated license is bellow. // https://github.com/samdmarshall/SDMMobileDevice/blob/master/Framework/MobileDevice/Error/SDMMD_Error.h +// +// Copyright (c) 2014, Sam Marshall +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the +// following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of Sam Marshall nor the names of its contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. static errorcode_to_id_t errorcode_to_id[] = { { 0xe8000001, "kAMDUndefinedError" }, { 0xe8000002, "kAMDBadHeaderError" }, From 0390522194aeb42e424d2b3ebe4e17d851127ca3 Mon Sep 17 00:00:00 2001 From: Julius Trinkunas Date: Tue, 15 Sep 2015 18:14:37 +0300 Subject: [PATCH 09/23] Add text for errors 0xe8008016 and 0xe8008017. --- src/errors.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/errors.h b/src/errors.h index fe8f42f..868c880 100644 --- a/src/errors.h +++ b/src/errors.h @@ -192,6 +192,8 @@ static errorcode_to_id_t errorcode_to_id[] = { // Errors without id->string mapping. { 0xe8008015, "A valid provisioning profile for this executable was not found." }, + { 0xe8008016, "The entitlements specified in your application’s Code Signing Entitlements file do not match those specified in your provisioning profile." }, + { 0xe8008017, "A signed resource has been added, modified, or deleted." }, { 0xe8008018, "The identity used to sign the executable is no longer valid. Please verify that your device’s clock is properly set, and that your signing certificate is not expired." }, { 0xe8008019, "The application does not have a valid signature." }, { 0xe800801c, "No code signature found." }, From d6216760e4ff33dd0478c2c8e0b090fa17a92575 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Tue, 6 Oct 2015 13:14:21 -0700 Subject: [PATCH 10/23] Fixes #153 - Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSString stringWithUTF8String:]: NULL cString' #153 --- src/ios-deploy.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ios-deploy.c b/src/ios-deploy.c index 779682f..82d6dae 100644 --- a/src/ios-deploy.c +++ b/src/ios-deploy.c @@ -1401,6 +1401,9 @@ void download_tree(AMDeviceRef device) afc_connection* afc_conn_p = NULL; char *dirname = NULL; + list_root = list_root? list_root : "/"; + target_filename = target_filename? target_filename : "."; + NSString* targetPath = [NSString pathWithComponents:@[ @(target_filename), @(list_root)] ]; mkdirp([targetPath stringByDeletingLastPathComponent]); @@ -1419,7 +1422,7 @@ void download_tree(AMDeviceRef device) } } - read_dir(houseFd, afc_conn_p, list_root?list_root:"/", copy_file_callback); + read_dir(houseFd, afc_conn_p, list_root, copy_file_callback); } while(0); From 545521954b99bc6d4e368cb99ea3abe5add65944 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Tue, 6 Oct 2015 13:18:50 -0700 Subject: [PATCH 11/23] Fixed typo in README example. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 262c8bc..fadcfb2 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ The commands below assume that you have an app called `my.app` with bundle id `b ios-deploy --exists --bundle_id com.apple.mobilemail // Download the Documents directory of the app *only* - ios-deploy --download=/Documents -bundle_id my.app.id --to ./my_download_location + ios-deploy --download=/Documents --bundle_id my.app.id --to ./my_download_location // List ids and names of connected devices ios-deploy -c From 5e7420502bd7b04a63e6da21a0fdeac72f11a5ab Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Tue, 6 Oct 2015 13:33:51 -0700 Subject: [PATCH 12/23] Fixes #56 - Assertion failed AMDeviceSecureTransferPath (app name has non-ASCII characters) --- src/ios-deploy.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ios-deploy.c b/src/ios-deploy.c index 82d6dae..733d591 100644 --- a/src/ios-deploy.c +++ b/src/ios-deploy.c @@ -735,7 +735,7 @@ void write_lldb_prep_cmds(AMDeviceRef device, CFURLRef disk_app_url) { rangeLLDB.length = CFStringGetLength(pmodule); if (args) { - CFStringRef cf_args = CFStringCreateWithCString(NULL, args, kCFStringEncodingASCII); + CFStringRef cf_args = CFStringCreateWithCString(NULL, args, kCFStringEncodingUTF8); CFStringFindAndReplace(cmds, CFSTR("{args}"), cf_args, range, 0); rangeLLDB.length = CFStringGetLength(pmodule); CFStringFindAndReplace(pmodule, CFSTR("{args}"), cf_args, rangeLLDB, 0); @@ -786,14 +786,14 @@ void write_lldb_prep_cmds(AMDeviceRef device, CFURLRef disk_app_url) { } strcat(python_file_path, ".py"); - CFStringRef cf_python_command = CFStringCreateWithCString(NULL, python_command, kCFStringEncodingASCII); + CFStringRef cf_python_command = CFStringCreateWithCString(NULL, python_command, kCFStringEncodingUTF8); CFStringFindAndReplace(cmds, CFSTR("{python_command}"), cf_python_command, range, 0); range.length = CFStringGetLength(cmds); - CFStringRef cf_python_file_path = CFStringCreateWithCString(NULL, python_file_path, kCFStringEncodingASCII); + CFStringRef cf_python_file_path = CFStringCreateWithCString(NULL, python_file_path, kCFStringEncodingUTF8); CFStringFindAndReplace(cmds, CFSTR("{python_file_path}"), cf_python_file_path, range, 0); range.length = CFStringGetLength(cmds); - CFDataRef cmds_data = CFStringCreateExternalRepresentation(NULL, cmds, kCFStringEncodingASCII, 0); + CFDataRef cmds_data = CFStringCreateExternalRepresentation(NULL, cmds, kCFStringEncodingUTF8, 0); char prep_cmds_path[300] = PREP_CMDS_PATH; if(device_id != NULL) strcat(prep_cmds_path, device_id); @@ -815,7 +815,7 @@ void write_lldb_prep_cmds(AMDeviceRef device, CFURLRef disk_app_url) { fwrite(extra_cmds, strlen(extra_cmds), 1, out); fclose(out); - CFDataRef pmodule_data = CFStringCreateExternalRepresentation(NULL, pmodule, kCFStringEncodingASCII, 0); + CFDataRef pmodule_data = CFStringCreateExternalRepresentation(NULL, pmodule, kCFStringEncodingUTF8, 0); out = fopen(python_file_path, "w"); fwrite(CFDataGetBytePtr(pmodule_data), CFDataGetLength(pmodule_data), 1, out); @@ -1229,7 +1229,7 @@ service_conn_t start_house_arrest_service(AMDeviceRef device) { on_error(@"Bundle id is not specified"); } - CFStringRef cf_bundle_id = CFStringCreateWithCString(NULL, bundle_id, kCFStringEncodingASCII); + CFStringRef cf_bundle_id = CFStringCreateWithCString(NULL, bundle_id, kCFStringEncodingUTF8); if (AMDeviceStartHouseArrestService(device, cf_bundle_id, 0, &houseFd, 0) != 0) { on_error(@"Unable to find bundle with id: %@", bundle_id); @@ -1301,7 +1301,7 @@ int app_exists(AMDeviceRef device) check_error(AMDeviceValidatePairing(device)); check_error(AMDeviceStartSession(device)); - CFStringRef cf_bundle_id = CFStringCreateWithCString(NULL, bundle_id, kCFStringEncodingASCII); + CFStringRef cf_bundle_id = CFStringCreateWithCString(NULL, bundle_id, kCFStringEncodingUTF8); NSArray *a = [NSArray arrayWithObjects:@"CFBundleIdentifier", nil]; NSDictionary *optionsDict = [NSDictionary dictionaryWithObject:a forKey:@"ReturnAttributes"]; @@ -1516,7 +1516,7 @@ void uninstall_app(AMDeviceRef device) { CFStringRef cf_uninstall_bundle_id = NULL; if (bundle_id != NULL) { - cf_uninstall_bundle_id = CFStringCreateWithCString(NULL, bundle_id, kCFStringEncodingASCII); + cf_uninstall_bundle_id = CFStringCreateWithCString(NULL, bundle_id, kCFStringEncodingUTF8); } else { on_error(@"Error: you need to pass in the bundle id, (i.e. --bundle_id com.my.app)"); } @@ -1554,7 +1554,7 @@ void handle_device(AMDeviceRef device) { return; } if (device_id != NULL) { - CFStringRef deviceCFSTR = CFStringCreateWithCString(NULL, device_id, kCFStringEncodingASCII); + CFStringRef deviceCFSTR = CFStringCreateWithCString(NULL, device_id, kCFStringEncodingUTF8); if (CFStringCompare(deviceCFSTR, found_device_id, kCFCompareCaseInsensitive) == kCFCompareEqualTo) { found_device = true; CFRelease(deviceCFSTR); @@ -1593,7 +1593,7 @@ void handle_device(AMDeviceRef device) { CFRetain(device); // don't know if this is necessary? - CFStringRef path = CFStringCreateWithCString(NULL, app_path, kCFStringEncodingASCII); + CFStringRef path = CFStringCreateWithCString(NULL, app_path, kCFStringEncodingUTF8); CFURLRef relative_url = CFURLCreateWithFileSystemPath(NULL, path, kCFURLPOSIXPathStyle, false); CFURLRef url = CFURLCopyAbsoluteURL(relative_url); @@ -1606,7 +1606,7 @@ void handle_device(AMDeviceRef device) { CFStringRef cf_uninstall_bundle_id = NULL; if (bundle_id != NULL) { - cf_uninstall_bundle_id = CFStringCreateWithCString(NULL, bundle_id, kCFStringEncodingASCII); + cf_uninstall_bundle_id = CFStringCreateWithCString(NULL, bundle_id, kCFStringEncodingUTF8); } else { cf_uninstall_bundle_id = get_bundle_id(url); } From 2a1844500b52bc5fc8bb33be9ca11eeb0afdc047 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Tue, 6 Oct 2015 13:43:28 -0700 Subject: [PATCH 13/23] Fixes #168 - Segmentation Fault 11 (when deploying an .ipa file) --- src/ios-deploy.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ios-deploy.c b/src/ios-deploy.c index 733d591..546991f 100644 --- a/src/ios-deploy.c +++ b/src/ios-deploy.c @@ -702,7 +702,10 @@ CFURLRef copy_device_app_url(AMDeviceRef device, CFStringRef identifier) { CFStringRef copy_disk_app_identifier(CFURLRef disk_app_url) { CFURLRef plist_url = CFURLCreateCopyAppendingPathComponent(NULL, disk_app_url, CFSTR("Info.plist"), false); CFReadStreamRef plist_stream = CFReadStreamCreateWithFile(NULL, plist_url); - CFReadStreamOpen(plist_stream); + if (!CFReadStreamOpen(plist_stream)) { + on_error(@"Cannot read Info.plist file: %@", plist_url); + } + CFPropertyListRef plist = CFPropertyListCreateWithStream(NULL, plist_stream, 0, kCFPropertyListImmutable, NULL, NULL); CFStringRef bundle_identifier = CFRetain(CFDictionaryGetValue(plist, CFSTR("CFBundleIdentifier"))); CFReadStreamClose(plist_stream); From ab39342b0fb4ca0d08ab947c4287d243adb4c80e Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Tue, 6 Oct 2015 14:00:42 -0700 Subject: [PATCH 14/23] Fixes #166 - Segfault when passed a non-existent bundle #166 --- src/ios-deploy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ios-deploy.c b/src/ios-deploy.c index 546991f..44d5369 100644 --- a/src/ios-deploy.c +++ b/src/ios-deploy.c @@ -218,7 +218,7 @@ void on_sys_error(NSString* format, ...) { NSString* str = [[[NSString alloc] initWithFormat:format arguments:valist] autorelease]; va_end(valist); - on_error(@"%@ : %@", str, errstr); + on_error(@"%@ : %@", str, [NSString stringWithUTF8String:errstr]); } void NSLogOut(NSString* format, ...) { @@ -1929,7 +1929,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 '%@'", app_path); + on_sys_error(@"Can't access app path '%@'", [NSString stringWithUTF8String:app_path]); } } From 4ce355456100e755d02091d2ec161b35dd02aebc Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Tue, 6 Oct 2015 15:39:57 -0700 Subject: [PATCH 15/23] Fixes #164 - Error when launch application in multi-user context --- src/ios-deploy.c | 86 +++++++++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 37 deletions(-) diff --git a/src/ios-deploy.c b/src/ios-deploy.c index 44d5369..779d003 100644 --- a/src/ios-deploy.c +++ b/src/ios-deploy.c @@ -19,8 +19,8 @@ #include "errors.h" #define APP_VERSION @"1.7.0" -#define PREP_CMDS_PATH "/tmp/fruitstrap-lldb-prep-cmds-" -#define LLDB_SHELL "lldb -s " PREP_CMDS_PATH +#define PREP_CMDS_PATH @"/tmp/%@/fruitstrap-lldb-prep-cmds-" +#define LLDB_SHELL @"lldb -s %@" /* * Startup script passed to lldb. * To see how xcode interacts with lldb, put this into .lldbinit: @@ -179,6 +179,7 @@ pid_t child = 0; // Signal sent from child to parent process when LLDB finishes. const int SIGLLDB = SIGUSR1; AMDeviceRef best_device_match = NULL; +NSString* tmpUUID; // Error codes we report on different failures, so scripts can distinguish between user app exit // codes and our exit codes. For non app errors we use codes in reserved 128-255 range. @@ -230,6 +231,15 @@ void NSLogOut(NSString* format, ...) { [[str stringByAppendingString:@"\n"] writeToFile:@"/dev/stdout" atomically:NO encoding:NSUTF8StringEncoding error:nil]; } +BOOL mkdirp(NSString* path) { + NSError* error = nil; + BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:path + withIntermediateDirectories:YES + attributes:nil + error:&error]; + return success; +} + Boolean path_exists(CFTypeRef path) { if (CFGetTypeID(path) == CFStringGetTypeID()) { CFURLRef url = CFURLCreateWithFileSystemPath(NULL, path, kCFURLPOSIXPathStyle, true); @@ -781,26 +791,27 @@ void write_lldb_prep_cmds(AMDeviceRef device, CFURLRef disk_app_url) { CFStringRef disk_container_path = CFURLCopyFileSystemPath(disk_container_url, kCFURLPOSIXPathStyle); CFStringFindAndReplace(cmds, CFSTR("{disk_container}"), disk_container_path, range, 0); - char python_file_path[300] = "/tmp/fruitstrap_"; - char python_command[300] = "fruitstrap_"; + NSString* python_file_path = [NSString stringWithFormat:@"/tmp/%@/fruitstrap_", tmpUUID]; + mkdirp(python_file_path); + + NSString* python_command = @"fruitstrap_"; if(device_id != NULL) { - strcat(python_file_path, device_id); - strcat(python_command, device_id); + python_file_path = [python_file_path stringByAppendingString:[NSString stringWithUTF8String:device_id]]; + python_command = [python_command stringByAppendingString:[NSString stringWithUTF8String:device_id]]; } - strcat(python_file_path, ".py"); + python_file_path = [python_file_path stringByAppendingString:@".py"]; - CFStringRef cf_python_command = CFStringCreateWithCString(NULL, python_command, kCFStringEncodingUTF8); - CFStringFindAndReplace(cmds, CFSTR("{python_command}"), cf_python_command, range, 0); + CFStringFindAndReplace(cmds, CFSTR("{python_command}"), (CFStringRef)python_command, range, 0); range.length = CFStringGetLength(cmds); - CFStringRef cf_python_file_path = CFStringCreateWithCString(NULL, python_file_path, kCFStringEncodingUTF8); - CFStringFindAndReplace(cmds, CFSTR("{python_file_path}"), cf_python_file_path, range, 0); + CFStringFindAndReplace(cmds, CFSTR("{python_file_path}"), (CFStringRef)python_file_path, range, 0); range.length = CFStringGetLength(cmds); CFDataRef cmds_data = CFStringCreateExternalRepresentation(NULL, cmds, kCFStringEncodingUTF8, 0); - char prep_cmds_path[300] = PREP_CMDS_PATH; - if(device_id != NULL) - strcat(prep_cmds_path, device_id); - FILE *out = fopen(prep_cmds_path, "w"); + NSString* prep_cmds_path = [NSString stringWithFormat:PREP_CMDS_PATH, tmpUUID]; + if(device_id != NULL) { + prep_cmds_path = [prep_cmds_path stringByAppendingString:[NSString stringWithUTF8String:device_id]]; + } + FILE *out = fopen([prep_cmds_path UTF8String], "w"); fwrite(CFDataGetBytePtr(cmds_data), CFDataGetLength(cmds_data), 1, out); // Write additional commands based on mode we're running in const char* extra_cmds; @@ -820,7 +831,7 @@ void write_lldb_prep_cmds(AMDeviceRef device, CFURLRef disk_app_url) { CFDataRef pmodule_data = CFStringCreateExternalRepresentation(NULL, pmodule, kCFStringEncodingUTF8, 0); - out = fopen(python_file_path, "w"); + out = fopen([python_file_path UTF8String], "w"); fwrite(CFDataGetBytePtr(pmodule_data), CFDataGetLength(pmodule_data), 1, out); fclose(out); @@ -836,8 +847,6 @@ void write_lldb_prep_cmds(AMDeviceRef device, CFURLRef disk_app_url) { CFRelease(disk_container_url); CFRelease(disk_container_path); CFRelease(cmds_data); - CFRelease(cf_python_command); - CFRelease(cf_python_file_path); } CFSocketRef server_socket; @@ -1053,12 +1062,15 @@ void launch_debugger(AMDeviceRef device, CFURLRef url) { // this we setup a dummy pipe on stdin, so read() would block expecting "user's" input. setup_dummy_pipe_on_stdin(pfd); - char lldb_shell[400]; - sprintf(lldb_shell, LLDB_SHELL); - if(device_id != NULL) - strcat(lldb_shell, device_id); + NSString* lldb_shell; + NSString* prep_cmds = [NSString stringWithFormat:PREP_CMDS_PATH, tmpUUID]; + lldb_shell = [NSString stringWithFormat:LLDB_SHELL, prep_cmds]; + + if(device_id != NULL) { + lldb_shell = [lldb_shell stringByAppendingString: [NSString stringWithUTF8String:device_id]]; + } - int status = system(lldb_shell); // launch lldb + int status = system([lldb_shell UTF8String]); // launch lldb if (status == -1) perror("failed launching lldb"); @@ -1090,12 +1102,14 @@ void launch_debugger_and_exit(AMDeviceRef device, CFURLRef url) { if (dup2(pfd[0],STDIN_FILENO) == -1) perror("dup2 failed"); - char lldb_shell[400]; - sprintf(lldb_shell, LLDB_SHELL); - if(device_id != NULL) - strcat(lldb_shell, device_id); - int status = system(lldb_shell); // launch lldb + NSString* prep_cmds = [NSString stringWithFormat:PREP_CMDS_PATH, tmpUUID]; + NSString* lldb_shell = [NSString stringWithFormat:LLDB_SHELL, prep_cmds]; + if(device_id != NULL) { + lldb_shell = [lldb_shell stringByAppendingString:[NSString stringWithUTF8String:device_id]]; + } + + int status = system([lldb_shell UTF8String]); // launch lldb if (status == -1) perror("failed launching lldb"); @@ -1389,15 +1403,6 @@ void copy_file_callback(afc_connection* afc_conn_p, const char *name,int file) } } -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) { service_conn_t houseFd = start_house_arrest_service(device); @@ -1781,6 +1786,13 @@ void show_version() { } int main(int argc, char *argv[]) { + + // create a UUID for tmp purposes + CFUUIDRef uuid = CFUUIDCreate(NULL); + CFStringRef str = CFUUIDCreateString(NULL, uuid); + CFRelease(uuid); + tmpUUID = [(NSString*)str autorelease]; + static struct option longopts[] = { { "debug", no_argument, NULL, 'd' }, { "id", required_argument, NULL, 'i' }, From 342965c16a0a3fbed9cb38c25ee857c184e9f6ae Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Tue, 6 Oct 2015 15:47:59 -0700 Subject: [PATCH 16/23] Added iPhone 6s and 6s Plus models. --- src/ios-deploy.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ios-deploy.c b/src/ios-deploy.c index 779d003..3ad9b25 100644 --- a/src/ios-deploy.c +++ b/src/ios-deploy.c @@ -431,6 +431,11 @@ const CFStringRef get_device_hardware_name(const AMDeviceRef device) { GET_FRIENDLY_MODEL_NAME(model, "N61AP", "iPhone 6 (GSM)") 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") + return model; } From a6e94923cf409af5f9d63297785882302bc628ae Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Tue, 6 Oct 2015 16:51:27 -0700 Subject: [PATCH 17/23] Fixes #170 - ios-deploy installing over both USB and WiFi --- src/MobileDevice.h | 4 ++++ src/ios-deploy.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/MobileDevice.h b/src/MobileDevice.h index d97eafb..8c9ff91 100644 --- a/src/MobileDevice.h +++ b/src/MobileDevice.h @@ -195,6 +195,10 @@ mach_error_t AMDeviceNotificationSubscribe(am_device_notification_callback callback, unsigned int unused0, unsigned int unused1, void* //unsigned int dn_unknown3, struct am_device_notification **notification); + +mach_error_t AMDeviceNotificationUnsubscribe(am_device_notification subscription); + + /* Connects to the iPhone. Pass in the am_device structure that the * notification callback will give to you. * diff --git a/src/ios-deploy.c b/src/ios-deploy.c index 3ad9b25..a2ddd19 100644 --- a/src/ios-deploy.c +++ b/src/ios-deploy.c @@ -180,6 +180,7 @@ pid_t child = 0; const int SIGLLDB = SIGUSR1; AMDeviceRef best_device_match = NULL; NSString* tmpUUID; +struct am_device_notification *notify; // Error codes we report on different failures, so scripts can distinguish between user app exit // codes and our exit codes. For non app errors we use codes in reserved 128-255 range. @@ -1709,7 +1710,8 @@ void device_callback(struct am_device_notification_callback_info *info, void *ar switch (info->msg) { case ADNCI_MSG_CONNECTED: if(device_id != NULL || !debug || AMDeviceGetInterfaceType(info->dev) != 2) { - handle_device(info->dev); + AMDeviceNotificationUnsubscribe(*notify); + handle_device(info->dev); } else if(best_device_match == NULL) { best_device_match = info->dev; CFRetain(best_device_match); @@ -1962,7 +1964,6 @@ int main(int argc, char *argv[]) { NSLogOut(@"[....] Waiting for iOS device to be connected"); } - struct am_device_notification *notify; AMDeviceNotificationSubscribe(&device_callback, 0, 0, NULL, ¬ify); CFRunLoopRun(); } From 2f9fb4304a1d5962f513f9444906ecf7cef69782 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Tue, 6 Oct 2015 17:11:14 -0700 Subject: [PATCH 18/23] Incremented version to 1.8.0 --- package.json | 4 ++-- src/ios-deploy.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index c040f38..1a1f71d 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "ios-deploy", - "version": "1.7.0", + "version": "1.8.0", "os" : [ "darwin" ], - "description": "launch iOS apps iOS devices from the command line (Xcode 6)", + "description": "launch iOS apps iOS devices from the command line (Xcode 7)", "main": "ios-deploy", "scripts": { "preinstall": "make ios-deploy" diff --git a/src/ios-deploy.c b/src/ios-deploy.c index a2ddd19..c0febc1 100644 --- a/src/ios-deploy.c +++ b/src/ios-deploy.c @@ -18,7 +18,7 @@ #include "MobileDevice.h" #include "errors.h" -#define APP_VERSION @"1.7.0" +#define APP_VERSION @"1.8.0" #define PREP_CMDS_PATH @"/tmp/%@/fruitstrap-lldb-prep-cmds-" #define LLDB_SHELL @"lldb -s %@" /* From 8d60757e770dcf6c047cb89b41d4a017c7eb41b2 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Tue, 6 Oct 2015 17:46:50 -0700 Subject: [PATCH 19/23] Fixes #167 - On El Cap, detect Xcode 7 properly installed --- check_reqs.js | 32 ++++++++++++++++++++++++++++++++ package.json | 11 ++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-) create mode 100755 check_reqs.js diff --git a/check_reqs.js b/check_reqs.js new file mode 100755 index 0000000..fda89da --- /dev/null +++ b/check_reqs.js @@ -0,0 +1,32 @@ +#!/usr/bin/env node + +var shell = require('shelljs'); +var util = require('util'); +var os = require('os'); + +var XCODEBUILD_MIN_VERSION = '6.4'; +var XCODEBUILD_NOT_FOUND_MESSAGE = + 'Please install Xcode version ' + XCODEBUILD_MIN_VERSION + ' or greater from App Store'; + +var tool = 'xcodebuild' +var tool_command = shell.which(tool); +if (!tool_command) { + console.log(tool + ' : ' + XCODEBUILD_NOT_FOUND_MESSAGE); + process.exit(1); +} + +shell.exec(tool + ' -version', { silent: true }, function(code, output) { + if (code === 0) { + var arr = output.match(/^Xcode (\d+\.\d+)/); + var ver = arr[1]; + + if (os.release() >= '15.0.0' && ver < '7.0') { + console.log(util.format('You need at least Xcode 7.0 on OS X 10.11 El Capitan (you have version %s)', ver)); + process.exit(1); + } + + if (ver < XCODEBUILD_MIN_VERSION) { + console.log(util.format('%s : %s. (you have version %s)', tool, XCODEBUILD_NOT_FOUND_MESSAGE, ver)); + } + } +}); \ No newline at end of file diff --git a/package.json b/package.json index 1a1f71d..564034a 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,22 @@ { "name": "ios-deploy", "version": "1.8.0", - "os" : [ "darwin" ], + "os": [ + "darwin" + ], "description": "launch iOS apps iOS devices from the command line (Xcode 7)", "main": "ios-deploy", "scripts": { - "preinstall": "make ios-deploy" + "preinstall": "./check_reqs.js && make ios-deploy" }, - "bin" : "./ios-deploy" , + "bin": "./ios-deploy", "repository": { "type": "git", "url": "https://github.com/phonegap/ios-deploy" }, + "dependencies": { + "shelljs": "^0.2.6" + }, "keywords": [ "ios-deploy", "deploy to iOS device" From 6b7b31d54a11ce7b51ec86b4cbf60657122cff06 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Tue, 6 Oct 2015 22:01:36 -0700 Subject: [PATCH 20/23] check_reqs - removed shelljs dependency --- check_reqs.js | 45 +++++++++++++++++++++++++++++---------------- package.json | 3 --- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/check_reqs.js b/check_reqs.js index fda89da..ce06b73 100755 --- a/check_reqs.js +++ b/check_reqs.js @@ -1,32 +1,45 @@ #!/usr/bin/env node -var shell = require('shelljs'); var util = require('util'); var os = require('os'); +var child_process = require('child_process'); var XCODEBUILD_MIN_VERSION = '6.4'; -var XCODEBUILD_NOT_FOUND_MESSAGE = - 'Please install Xcode version ' + XCODEBUILD_MIN_VERSION + ' or greater from App Store'; - -var tool = 'xcodebuild' -var tool_command = shell.which(tool); -if (!tool_command) { - console.log(tool + ' : ' + XCODEBUILD_NOT_FOUND_MESSAGE); - process.exit(1); -} +var XCODEBUILD_NOT_FOUND_MESSAGE = util.format('Please install Xcode version %s or greater from the Mac App Store.', XCODEBUILD_MIN_VERSION); +var TOOL = 'xcodebuild'; -shell.exec(tool + ' -version', { silent: true }, function(code, output) { +var xcode_version = child_process.spawn(TOOL, ['-version']), + version_string = ''; + +xcode_version.stdout.on('data', function (data) { + version_string += data; +}); + +xcode_version.stderr.on('data', function (data) { + console.log('stderr: ' + data); +}); + +xcode_version.on('error', function (err) { + console.log(util.format('Tool %s was not found. %s', TOOL, XCODEBUILD_NOT_FOUND_MESSAGE)); +}); + +xcode_version.on('close', function (code) { if (code === 0) { - var arr = output.match(/^Xcode (\d+\.\d+)/); + var arr = version_string.match(/^Xcode (\d+\.\d+)/); var ver = arr[1]; if (os.release() >= '15.0.0' && ver < '7.0') { - console.log(util.format('You need at least Xcode 7.0 on OS X 10.11 El Capitan (you have version %s)', ver)); + console.log(util.format('You need at least Xcode 7.0 when you are on OS X 10.11 El Capitan (you have version %s)', ver)); process.exit(1); } - + if (ver < XCODEBUILD_MIN_VERSION) { console.log(util.format('%s : %s. (you have version %s)', tool, XCODEBUILD_NOT_FOUND_MESSAGE, ver)); } - } -}); \ No newline at end of file + } + process.exit(code); +}); + + + + diff --git a/package.json b/package.json index 564034a..c279b07 100644 --- a/package.json +++ b/package.json @@ -14,9 +14,6 @@ "type": "git", "url": "https://github.com/phonegap/ios-deploy" }, - "dependencies": { - "shelljs": "^0.2.6" - }, "keywords": [ "ios-deploy", "deploy to iOS device" From ede5d2542d71d24208b492ce8e750abdc81c1e44 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Tue, 6 Oct 2015 22:06:28 -0700 Subject: [PATCH 21/23] Fixes #156 - --list command add trailing slash for directories --- src/ios-deploy.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ios-deploy.c b/src/ios-deploy.c index c0febc1..a2cae06 100644 --- a/src/ios-deploy.c +++ b/src/ios-deploy.c @@ -1182,8 +1182,6 @@ void read_dir(service_conn_t afcFd, afc_connection* afc_conn_p, const char* dir, AFCConnectionOpen(afcFd, 0, &afc_conn_p); } - NSLogOut(@"%@", [NSString stringWithUTF8String:dir]); - afc_dictionary* afc_dict_p; char *key, *val; int not_dir = 0; @@ -1201,6 +1199,12 @@ void read_dir(service_conn_t afcFd, afc_connection* afc_conn_p, const char* dir, } } AFCKeyValueClose(afc_dict_p); + + if (not_dir) { + NSLogOut(@"%@", [NSString stringWithUTF8String:dir]); + } else { + NSLogOut(@"%@/", [NSString stringWithUTF8String:dir]); + } if (not_dir) { if (callback) (*callback)(afc_conn_p, dir, not_dir); From 6ce22c2adc3e344e8afeb7128976eb57ef6c7127 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Tue, 6 Oct 2015 22:13:04 -0700 Subject: [PATCH 22/23] Fixes #176 - Add documentation issue for node preinstall script (workaround) --- README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fadcfb2..7935506 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ Install and debug iOS apps without using Xcode. Designed to work on un-jailbroke ## Requirements -* Mac OS X. Tested on 10.10 Yosemite and iOS 8.3 +* Mac OS X. Tested on 10.11 El Capitan and iOS 9.0 * You need to have a valid iOS Development certificate installed. -* Xcode 6 or greater should be installed +* Xcode 6.4 or greater should be installed ## Roadmap @@ -40,6 +40,14 @@ make install prefix=/usr/local This will install ios-deploy in the `bin` folder of `/usr/local`, i.e. `/usr/local/bin` + +### OS X 10.11 El Capitan + +If you are *not* using a node version manager like [nvm](https://github.com/creationix/nvm) or [n](https://github.com/tj/n), you may have to do either of these two things below when under El Capitan: + +1. Add the `--unsafe-perm` flag when installing ios-deploy +2. Ensure the `nobody` user has write access to `/usr/local/lib/node_modules/ios-deploy/ios-deploy` + ## Usage Usage: ios-deploy [OPTION]... @@ -113,7 +121,7 @@ The commands below assume that you have an app called `my.app` with bundle id `b The included demo.app represents the minimum required to get code running on iOS. -* `make demo.app` will generate the demo.app executable. If it doesn't compile, modify IOS_SDK_VERSION in the Makefile. +* `make demo.app` will generate the demo.app executable. If it doesn't compile, modify `IOS_SDK_VERSION` in the Makefile. * `make debug` will install demo.app and launch a LLDB session. ## Notes From 5d2166fcef79b44ade04474b8171b03321ff8bca Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Tue, 6 Oct 2015 22:23:59 -0700 Subject: [PATCH 23/23] Fixes #135 - Convert Makefile to xcodeproject. Demo in its own folder now with its own Makefile. --- .gitignore | 5 +- Makefile | 35 -------- demo/.gitignore | 5 ++ demo/Entitlements.plist | 8 ++ demo/Info.plist | 24 +++++ demo/Makefile | 24 +++++ demo/ResourceRules.plist | 25 ++++++ demo/demo.c | 9 ++ ios-deploy-demo/main.m | 17 ---- ios-deploy.xcodeproj/project.pbxproj | 125 +-------------------------- package.json | 4 +- 11 files changed, 101 insertions(+), 180 deletions(-) delete mode 100644 Makefile create mode 100644 demo/.gitignore create mode 100644 demo/Entitlements.plist create mode 100644 demo/Info.plist create mode 100644 demo/Makefile create mode 100644 demo/ResourceRules.plist create mode 100644 demo/demo.c delete mode 100644 ios-deploy-demo/main.m diff --git a/.gitignore b/.gitignore index d3423ee..33dbe44 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ -demo -demo.app -ios-deploy -ios-deploy.dSYM +build/* /.DS_Store *~ diff --git a/Makefile b/Makefile deleted file mode 100644 index 26974ee..0000000 --- a/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -IOS_SDK_VERSION = 8.3 - -IOS_CC = gcc -ObjC -DEVICE_SUPPORT = $(shell xcode-select --print-path)/Platforms/iPhoneOS.platform/DeviceSupport -IOS_SDK = $(shell xcode-select --print-path)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$(IOS_SDK_VERSION).sdk - -all: clean ios-deploy demo.app - -demo.app: demo Info.plist - mkdir -p demo.app - cp demo demo.app/ - cp Info.plist ResourceRules.plist demo.app/ - codesign -f -s "iPhone Developer" --entitlements Entitlements.plist demo.app - -demo: demo.c - $(IOS_CC) -g -arch armv7 -isysroot $(IOS_SDK) -framework CoreFoundation -o demo demo.c - -ios-deploy: clean ios-deploy.c - $(IOS_CC) -g -o ios-deploy -framework Foundation -framework CoreFoundation -framework MobileDevice -F/System/Library/PrivateFrameworks ios-deploy.c - -symlink: - cd $(DEVICE_SUPPORT); ln -sfn "`find . -type d -maxdepth 1 -exec basename {} \; | tail -1`" Latest - -install: symlink ios-deploy - mkdir -p $(prefix)/bin - cp ios-deploy $(prefix)/bin - -uninstall: - rm $(prefix)/bin/ios-deploy - -debug: all - ./ios-deploy --debug --bundle demo.app - -clean: - @rm -rf *.app demo ios-deploy diff --git a/demo/.gitignore b/demo/.gitignore new file mode 100644 index 0000000..c2ef55d --- /dev/null +++ b/demo/.gitignore @@ -0,0 +1,5 @@ +demo +demo.app +demo.dSYM +/.DS_Store +*~ diff --git a/demo/Entitlements.plist b/demo/Entitlements.plist new file mode 100644 index 0000000..929c4e9 --- /dev/null +++ b/demo/Entitlements.plist @@ -0,0 +1,8 @@ + + + + + get-task-allow + + + \ No newline at end of file diff --git a/demo/Info.plist b/demo/Info.plist new file mode 100644 index 0000000..c2ade14 --- /dev/null +++ b/demo/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleName + demo + CFBundleSupportedPlatforms + + iPhoneOS + + CFBundleExecutable + demo + CFBundleVersion + 1.0 + CFBundleIdentifier + demo + CFBundleResourceSpecification + ResourceRules.plist + LSRequiresIPhoneOS + + CFBundleDisplayName + demo + + \ No newline at end of file diff --git a/demo/Makefile b/demo/Makefile new file mode 100644 index 0000000..cf7c36a --- /dev/null +++ b/demo/Makefile @@ -0,0 +1,24 @@ +IOS_SDK_VERSION = 9.0 + +IOS_CC = gcc -ObjC +IOS_SDK = $(shell xcode-select --print-path)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$(IOS_SDK_VERSION).sdk + +all: clean demo.app + +demo.app: demo Info.plist + mkdir -p demo.app + cp demo demo.app/ + cp Info.plist ResourceRules.plist demo.app/ + codesign -f -s "iPhone Developer" --entitlements Entitlements.plist demo.app + +demo: demo.c + $(IOS_CC) -g -arch armv7 -isysroot $(IOS_SDK) -framework CoreFoundation -o demo demo.c + +debug: all ios-deploy + @../build/Release/ios-deploy --debug --bundle demo.app + +clean: + @rm -rf *.app demo demo.dSYM + +ios-deploy: + @xcodebuild -project ../ios-deploy.xcodeproj diff --git a/demo/ResourceRules.plist b/demo/ResourceRules.plist new file mode 100644 index 0000000..e7ec329 --- /dev/null +++ b/demo/ResourceRules.plist @@ -0,0 +1,25 @@ + + + + + rules + + .* + + Info.plist + + omit + + weight + 10 + + ResourceRules.plist + + omit + + weight + 100 + + + + diff --git a/demo/demo.c b/demo/demo.c new file mode 100644 index 0000000..b366b14 --- /dev/null +++ b/demo/demo.c @@ -0,0 +1,9 @@ +#include + +int main(int argc, const char* argv[]) { + int i; + for (i = 0; i < argc; i++) { + printf("argv[%d] = %s\n", i, argv[i]); + } + return 0; +} \ No newline at end of file diff --git a/ios-deploy-demo/main.m b/ios-deploy-demo/main.m deleted file mode 100644 index c64512e..0000000 --- a/ios-deploy-demo/main.m +++ /dev/null @@ -1,17 +0,0 @@ -// -// main.m -// ios-deploy-demo -// -// Created by shazron on 7/16/15. -// Copyright (c) 2015 PhoneGap. All rights reserved. -// - -#import - -int main(int argc, const char * argv[]) { - @autoreleasepool { - // insert code here... - NSLog(@"Hello, World!"); - } - return 0; -} diff --git a/ios-deploy.xcodeproj/project.pbxproj b/ios-deploy.xcodeproj/project.pbxproj index 63e2385..2b26eb1 100644 --- a/ios-deploy.xcodeproj/project.pbxproj +++ b/ios-deploy.xcodeproj/project.pbxproj @@ -10,8 +10,6 @@ 7E70899C1B587DE4004D23AA /* ios-deploy.c in Sources */ = {isa = PBXBuildFile; fileRef = 7E7089991B587DE4004D23AA /* ios-deploy.c */; settings = {COMPILER_FLAGS = "-x objective-c -fno-objc-arc"; }; }; 7E70899E1B587F29004D23AA /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E70899D1B587F29004D23AA /* CoreFoundation.framework */; }; 7E7089A01B58801E004D23AA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E70899F1B58801E004D23AA /* Foundation.framework */; }; - 7E7089B31B58826A004D23AA /* demo.c in Sources */ = {isa = PBXBuildFile; fileRef = 7E7089AF1B58826A004D23AA /* demo.c */; }; - 7E7089B41B5882C3004D23AA /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E70899D1B587F29004D23AA /* CoreFoundation.framework */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -24,15 +22,6 @@ ); runOnlyForDeploymentPostprocessing = 1; }; - 7E7089A51B58825B004D23AA /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = /usr/share/man/man1/; - dstSubfolderSpec = 0; - files = ( - ); - runOnlyForDeploymentPostprocessing = 1; - }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ @@ -42,12 +31,6 @@ 7E70899B1B587DE4004D23AA /* MobileDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MobileDevice.h; path = src/MobileDevice.h; sourceTree = SOURCE_ROOT; }; 7E70899D1B587F29004D23AA /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; 7E70899F1B58801E004D23AA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - 7E7089A71B58825B004D23AA /* ios-deploy-demo */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "ios-deploy-demo"; sourceTree = BUILT_PRODUCTS_DIR; }; - 7E7089A91B58825B004D23AA /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - 7E7089AF1B58826A004D23AA /* demo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = demo.c; sourceTree = ""; }; - 7E7089B01B58826A004D23AA /* Entitlements.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Entitlements.plist; sourceTree = ""; }; - 7E7089B11B58826A004D23AA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 7E7089B21B58826A004D23AA /* ResourceRules.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = ResourceRules.plist; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -60,23 +43,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 7E7089A41B58825B004D23AA /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 7E7089B41B5882C3004D23AA /* CoreFoundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 7E7089851B587BF3004D23AA = { isa = PBXGroup; children = ( - 7E7089AE1B58826A004D23AA /* demo */, 7E7089901B587BF3004D23AA /* ios-deploy */, - 7E7089A81B58825B004D23AA /* ios-deploy-demo */, 7E7089A21B588219004D23AA /* Frameworks */, 7E70898F1B587BF3004D23AA /* Products */, ); @@ -86,7 +59,6 @@ isa = PBXGroup; children = ( 7E70898E1B587BF3004D23AA /* ios-deploy */, - 7E7089A71B58825B004D23AA /* ios-deploy-demo */, ); name = Products; sourceTree = ""; @@ -110,25 +82,6 @@ name = Frameworks; sourceTree = ""; }; - 7E7089A81B58825B004D23AA /* ios-deploy-demo */ = { - isa = PBXGroup; - children = ( - 7E7089A91B58825B004D23AA /* main.m */, - ); - path = "ios-deploy-demo"; - sourceTree = ""; - }; - 7E7089AE1B58826A004D23AA /* demo */ = { - isa = PBXGroup; - children = ( - 7E7089AF1B58826A004D23AA /* demo.c */, - 7E7089B01B58826A004D23AA /* Entitlements.plist */, - 7E7089B11B58826A004D23AA /* Info.plist */, - 7E7089B21B58826A004D23AA /* ResourceRules.plist */, - ); - path = demo; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -149,39 +102,18 @@ productReference = 7E70898E1B587BF3004D23AA /* ios-deploy */; productType = "com.apple.product-type.tool"; }; - 7E7089A61B58825B004D23AA /* ios-deploy-demo */ = { - isa = PBXNativeTarget; - buildConfigurationList = 7E7089AB1B58825B004D23AA /* Build configuration list for PBXNativeTarget "ios-deploy-demo" */; - buildPhases = ( - 7E7089A31B58825B004D23AA /* Sources */, - 7E7089A41B58825B004D23AA /* Frameworks */, - 7E7089A51B58825B004D23AA /* CopyFiles */, - 7E7089B51B5882EC004D23AA /* ShellScript */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "ios-deploy-demo"; - productName = "ios-deploy-demo"; - productReference = 7E7089A71B58825B004D23AA /* ios-deploy-demo */; - productType = "com.apple.product-type.tool"; - }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 7E7089861B587BF3004D23AA /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0640; + LastUpgradeCheck = 0710; ORGANIZATIONNAME = PhoneGap; TargetAttributes = { 7E70898D1B587BF3004D23AA = { CreatedOnToolsVersion = 6.4; }; - 7E7089A61B58825B004D23AA = { - CreatedOnToolsVersion = 6.4; - }; }; }; buildConfigurationList = 7E7089891B587BF3004D23AA /* Build configuration list for PBXProject "ios-deploy" */; @@ -190,6 +122,7 @@ hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = 7E7089851B587BF3004D23AA; productRefGroup = 7E70898F1B587BF3004D23AA /* Products */; @@ -197,27 +130,10 @@ projectRoot = ""; targets = ( 7E70898D1B587BF3004D23AA /* ios-deploy */, - 7E7089A61B58825B004D23AA /* ios-deploy-demo */, ); }; /* End PBXProject section */ -/* Begin PBXShellScriptBuildPhase section */ - 7E7089B51B5882EC004D23AA /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "#mkdir -p demo.app\n#cp demo demo.app/\n#cp Info.plist ResourceRules.plist demo.app/\n#codesign -f -s \"iPhone Developer\" --entitlements Entitlements.plist demo.app"; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ 7E70898A1B587BF3004D23AA /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -227,14 +143,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 7E7089A31B58825B004D23AA /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 7E7089B31B58826A004D23AA /* demo.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXSourcesBuildPhase section */ /* Begin XCBuildConfiguration section */ @@ -258,6 +166,7 @@ COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -339,26 +248,6 @@ }; name = Release; }; - 7E7089AC1B58825B004D23AA /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - MACOSX_DEPLOYMENT_TARGET = 10.8; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - 7E7089AD1B58825B004D23AA /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - MACOSX_DEPLOYMENT_TARGET = 10.8; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -380,14 +269,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 7E7089AB1B58825B004D23AA /* Build configuration list for PBXNativeTarget "ios-deploy-demo" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 7E7089AC1B58825B004D23AA /* Debug */, - 7E7089AD1B58825B004D23AA /* Release */, - ); - defaultConfigurationIsVisible = 0; - }; /* End XCConfigurationList section */ }; rootObject = 7E7089861B587BF3004D23AA /* Project object */; diff --git a/package.json b/package.json index c279b07..cd4bdfb 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,9 @@ "description": "launch iOS apps iOS devices from the command line (Xcode 7)", "main": "ios-deploy", "scripts": { - "preinstall": "./check_reqs.js && make ios-deploy" + "preinstall": "./check_reqs.js && xcodebuild" }, - "bin": "./ios-deploy", + "bin": "./build/Release/ios-deploy", "repository": { "type": "git", "url": "https://github.com/phonegap/ios-deploy"