Compare commits
82 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f6b41519b | ||
|
|
5d2166fcef | ||
|
|
6ce22c2adc | ||
|
|
ede5d2542d | ||
|
|
6b7b31d54a | ||
|
|
8d60757e77 | ||
|
|
2f9fb4304a | ||
|
|
a6e94923cf | ||
|
|
342965c16a | ||
|
|
4ce3554561 | ||
|
|
ab39342b0f | ||
|
|
2a1844500b | ||
|
|
5e7420502b | ||
|
|
545521954b | ||
|
|
d6216760e4 | ||
|
|
0390522194 | ||
|
|
ca2e7a3c75 | ||
|
|
ed7c70aa59 | ||
|
|
093b4b3c9a | ||
|
|
4d58838ef1 | ||
|
|
d10562c501 | ||
|
|
99dba4e58c | ||
|
|
bf58b61561 | ||
|
|
d2aee71a92 | ||
|
|
92f6238bba | ||
|
|
6aa7b57014 | ||
|
|
55d076b805 | ||
|
|
3756385651 | ||
|
|
adc8a5b9c2 | ||
|
|
bb25caf586 | ||
|
|
75820a0979 | ||
|
|
16f52589db | ||
|
|
21c8dc9cf5 | ||
|
|
34540ce545 | ||
|
|
7b834b0e31 | ||
|
|
7ac9cdb107 | ||
|
|
cf9d024a2b | ||
|
|
4d4735e505 | ||
|
|
2c9ea8f16e | ||
|
|
5eb12202b2 | ||
|
|
307a5f9452 | ||
|
|
835e161f66 | ||
|
|
73f30fdfed | ||
|
|
be506a9f7f | ||
|
|
bc1bb0d320 | ||
|
|
7d997b89c7 | ||
|
|
6d61b7ca7c | ||
|
|
590da67714 | ||
|
|
8749a57936 | ||
|
|
3ba7403a39 | ||
|
|
84aeaad03b | ||
|
|
ddcb4932ab | ||
|
|
11f1a89128 | ||
|
|
c97b972172 | ||
|
|
1cb6110985 | ||
|
|
3dadb53b3b | ||
|
|
39aa232f97 | ||
|
|
609b635870 | ||
|
|
522f7bd667 | ||
|
|
250794ce98 | ||
|
|
41eeedc472 | ||
|
|
cdbe112ec6 | ||
|
|
5377d9bec7 | ||
|
|
5d2a0d5c8b | ||
|
|
e5fc979998 | ||
|
|
18873b8340 | ||
|
|
ed09a029de | ||
|
|
a750efa382 | ||
|
|
0940a4d079 | ||
|
|
b72d31b816 | ||
|
|
5690b10635 | ||
|
|
d90171d8e7 | ||
|
|
02c23792ee | ||
|
|
3e8a897fbc | ||
|
|
ba60ff6351 | ||
|
|
134a0a5fd0 | ||
|
|
96e91eb269 | ||
|
|
8577ef3411 | ||
|
|
99f401018d | ||
|
|
6ac084844e | ||
|
|
3dcd64f7c0 | ||
|
|
12334f8ddf |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,6 +1,3 @@
|
||||
demo
|
||||
demo.app
|
||||
ios-deploy
|
||||
ios-deploy.dSYM
|
||||
build/*
|
||||
/.DS_Store
|
||||
*~
|
||||
|
||||
6
LICENSE
6
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
|
||||
|
||||
35
Makefile
35
Makefile
@@ -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
|
||||
31
README.md
31
README.md
@@ -4,11 +4,21 @@ 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
|
||||
|
||||
See our [milestones](https://github.com/phonegap/ios-deploy/milestones).
|
||||
|
||||
Significant changes:
|
||||
|
||||
1.8.0 will use an Xcode project instead of a Makefile (to prepare for 2.0.0)
|
||||
2.0.0 will break out the commands into their own files, and create ios-deploy-lib for node.js use
|
||||
|
||||
## Installation
|
||||
=======
|
||||
|
||||
ios-deploy installation is made simple using the node.js package manager. If you use [Homebrew](http://brew.sh/), install [node.js](https://nodejs.org):
|
||||
|
||||
@@ -30,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]...
|
||||
@@ -57,7 +75,7 @@ This will install ios-deploy in the `bin` folder of `/usr/local`, i.e. `/usr/loc
|
||||
-R, --rm <path> remove file or directory on device (directories must be empty)
|
||||
-V, --version print the executable version
|
||||
-e, --exists check if the app with given bundle_id is installed or not
|
||||
|
||||
-B, --list_bundle_id list bundle_id
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -88,19 +106,22 @@ 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
|
||||
|
||||
// Uninstall an app
|
||||
ios-deploy --uninstall_only --bundle_id my.bundle.id
|
||||
|
||||
// list all bundle ids of all apps on your device
|
||||
ios-deploy --list_bundle_id
|
||||
|
||||
## Demo
|
||||
|
||||
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
|
||||
|
||||
45
check_reqs.js
Executable file
45
check_reqs.js
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
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 = util.format('Please install Xcode version %s or greater from the Mac App Store.', XCODEBUILD_MIN_VERSION);
|
||||
var TOOL = 'xcodebuild';
|
||||
|
||||
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 = 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 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));
|
||||
}
|
||||
}
|
||||
process.exit(code);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
5
demo/.gitignore
vendored
Normal file
5
demo/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
demo
|
||||
demo.app
|
||||
demo.dSYM
|
||||
/.DS_Store
|
||||
*~
|
||||
24
demo/Makefile
Normal file
24
demo/Makefile
Normal file
@@ -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
|
||||
@@ -6,4 +6,4 @@ int main(int argc, const char* argv[]) {
|
||||
printf("argv[%d] = %s\n", i, argv[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
275
ios-deploy.xcodeproj/project.pbxproj
Normal file
275
ios-deploy.xcodeproj/project.pbxproj
Normal file
@@ -0,0 +1,275 @@
|
||||
// !$*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 */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
7E70898C1B587BF3004D23AA /* 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; };
|
||||
/* 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;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
7E7089851B587BF3004D23AA = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7E7089901B587BF3004D23AA /* ios-deploy */,
|
||||
7E7089A21B588219004D23AA /* Frameworks */,
|
||||
7E70898F1B587BF3004D23AA /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7E70898F1B587BF3004D23AA /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7E70898E1B587BF3004D23AA /* ios-deploy */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7E7089901B587BF3004D23AA /* ios-deploy */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7E7089991B587DE4004D23AA /* ios-deploy.c */,
|
||||
7E70899A1B587DE4004D23AA /* errors.h */,
|
||||
7E70899B1B587DE4004D23AA /* MobileDevice.h */,
|
||||
);
|
||||
path = "ios-deploy";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7E7089A21B588219004D23AA /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7E70899F1B58801E004D23AA /* Foundation.framework */,
|
||||
7E70899D1B587F29004D23AA /* CoreFoundation.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* 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";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
7E7089861B587BF3004D23AA /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0710;
|
||||
ORGANIZATIONNAME = PhoneGap;
|
||||
TargetAttributes = {
|
||||
7E70898D1B587BF3004D23AA = {
|
||||
CreatedOnToolsVersion = 6.4;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 7E7089891B587BF3004D23AA /* Build configuration list for PBXProject "ios-deploy" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 7E7089851B587BF3004D23AA;
|
||||
productRefGroup = 7E70898F1B587BF3004D23AA /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
7E70898D1B587BF3004D23AA /* ios-deploy */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
7E70898A1B587BF3004D23AA /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
7E70899C1B587DE4004D23AA /* ios-deploy.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;
|
||||
ENABLE_TESTABILITY = 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;
|
||||
};
|
||||
/* 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;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 7E7089861B587BF3004D23AA /* Project object */;
|
||||
}
|
||||
12
package.json
12
package.json
@@ -1,13 +1,15 @@
|
||||
{
|
||||
"name": "ios-deploy",
|
||||
"version": "1.6.2",
|
||||
"os" : [ "darwin" ],
|
||||
"description": "launch iOS apps iOS devices from the command line (Xcode 6)",
|
||||
"version": "1.8.0",
|
||||
"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 && xcodebuild"
|
||||
},
|
||||
"bin" : "./ios-deploy" ,
|
||||
"bin": "./build/Release/ios-deploy",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phonegap/ios-deploy"
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
echo "$ make"
|
||||
make
|
||||
@@ -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.
|
||||
*
|
||||
@@ -9,7 +9,29 @@ 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
|
||||
// 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" },
|
||||
@@ -168,7 +190,13 @@ static errorcode_to_id_t errorcode_to_id[] = {
|
||||
{ 0xe800009b, "kAMDMCChallengeRequired" },
|
||||
{ 0xe800009c, "kAMDMissingBundleVersionError" },
|
||||
|
||||
{ 0xe8008015, "A valid provisioning profile for this executable was not found."},
|
||||
// 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." },
|
||||
};
|
||||
|
||||
const int errorcode_to_id_count = sizeof(errorcode_to_id) / sizeof(errorcode_to_id_t);
|
||||
@@ -18,9 +18,9 @@
|
||||
#include "MobileDevice.h"
|
||||
#include "errors.h"
|
||||
|
||||
#define APP_VERSION "1.6.2"
|
||||
#define PREP_CMDS_PATH "/tmp/fruitstrap-lldb-prep-cmds-"
|
||||
#define LLDB_SHELL "lldb -s " PREP_CMDS_PATH
|
||||
#define APP_VERSION @"1.8.0"
|
||||
#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:
|
||||
@@ -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;
|
||||
@@ -179,6 +179,8 @@ 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;
|
||||
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.
|
||||
@@ -192,33 +194,51 @@ const int exitcode_app_crash = 254;
|
||||
if (err != 0) \
|
||||
{ \
|
||||
const char* msg = get_error_message(err); \
|
||||
on_error("Error 0x%x: %s " #call, err, msg ? msg : "unknown."); \
|
||||
/*on_error("Error 0x%x: %s " #call, err, msg ? msg : "unknown.");*/ \
|
||||
on_error(@"Error 0x%x: %@ " #call, err, msg ? [NSString stringWithUTF8String:msg] : @"unknown."); \
|
||||
} \
|
||||
} while (false);
|
||||
|
||||
// Print error message and exit
|
||||
void on_error(const char* fmt, ...) {
|
||||
char buf[256];
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
fprintf(stderr, "[ !! ] ");
|
||||
vfprintf(stderr, fmt, args);
|
||||
fprintf(stderr, "\n");
|
||||
va_end(args);
|
||||
void on_error(NSString* format, ...)
|
||||
{
|
||||
va_list valist;
|
||||
va_start(valist, format);
|
||||
NSString* str = [[[NSString alloc] initWithFormat:format arguments:valist] autorelease];
|
||||
va_end(valist);
|
||||
|
||||
NSLog(@"[ !! ] %@", str);
|
||||
|
||||
exit(exitcode_error);
|
||||
}
|
||||
|
||||
// Print error message getting last errno and exit
|
||||
void on_sys_error(const char* fmt, ...) {
|
||||
void on_sys_error(NSString* format, ...) {
|
||||
const char* errstr = strerror(errno);
|
||||
|
||||
char buf[256];
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buf, 256, fmt, args);
|
||||
on_error("%s: %s", buf, errstr);
|
||||
va_end(args);
|
||||
va_list valist;
|
||||
va_start(valist, format);
|
||||
NSString* str = [[[NSString alloc] initWithFormat:format arguments:valist] autorelease];
|
||||
va_end(valist);
|
||||
|
||||
on_error(@"%@ : %@", str, [NSString stringWithUTF8String:errstr]);
|
||||
}
|
||||
|
||||
void NSLogOut(NSString* format, ...) {
|
||||
va_list valist;
|
||||
va_start(valist, format);
|
||||
NSString* str = [[[NSString alloc] initWithFormat:format arguments:valist] autorelease];
|
||||
va_end(valist);
|
||||
|
||||
[[str stringByAppendingString:@"\n"] writeToFile:@"/dev/stdout" atomically:NO encoding:NSUTF8StringEncoding error:nil];
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -260,7 +280,7 @@ CFStringRef find_path(CFStringRef rootPath, CFStringRef namePattern, CFStringRef
|
||||
CFRelease(cf_command);
|
||||
|
||||
if (!(fpipe = (FILE *)popen(command, "r")))
|
||||
on_sys_error("Error encountered while opening pipe");
|
||||
on_sys_error(@"Error encountered while opening pipe");
|
||||
|
||||
char buffer[256] = { '\0' };
|
||||
|
||||
@@ -282,7 +302,7 @@ CFStringRef copy_xcode_dev_path() {
|
||||
char *command = "xcode-select -print-path";
|
||||
|
||||
if (!(fpipe = (FILE *)popen(command, "r")))
|
||||
on_sys_error("Error encountered while opening pipe");
|
||||
on_sys_error(@"Error encountered while opening pipe");
|
||||
|
||||
char buffer[256] = { '\0' };
|
||||
|
||||
@@ -306,7 +326,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;
|
||||
@@ -412,6 +432,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;
|
||||
}
|
||||
|
||||
@@ -445,18 +470,8 @@ CFStringRef get_device_full_name(const AMDeviceRef device) {
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
char *devName = MYCFStringCopyUTF8String(device_name);
|
||||
printf("Device Name:[%s]\n",devName);
|
||||
CFShow(device_name);
|
||||
printf("\n");
|
||||
free(devName);
|
||||
|
||||
char *mdlName = MYCFStringCopyUTF8String(model_name);
|
||||
printf("Model Name:[%s]\n",mdlName);
|
||||
printf("MM: [%s]\n",CFStringGetCStringPtr(model_name, kCFStringEncodingUTF8));
|
||||
CFShow(model_name);
|
||||
printf("\n");
|
||||
free(mdlName);
|
||||
NSLogOut(@"Device Name: %@", device_name);
|
||||
NSLogOut(@"Model Name: %@", model_name);
|
||||
}
|
||||
|
||||
if(device_name != NULL && model_name != NULL)
|
||||
@@ -535,7 +550,7 @@ CFStringRef copy_device_support_path(AMDeviceRef device) {
|
||||
CFRelease(build);
|
||||
|
||||
if (path == NULL)
|
||||
on_error("Unable to locate DeviceSupport directory. This probably means you don't have Xcode installed, you will need to launch the app manually and logging output will not be shown!");
|
||||
on_error(@"Unable to locate DeviceSupport directory. This probably means you don't have Xcode installed, you will need to launch the app manually and logging output will not be shown!");
|
||||
|
||||
return path;
|
||||
}
|
||||
@@ -573,7 +588,7 @@ CFStringRef copy_developer_disk_image_path(AMDeviceRef device) {
|
||||
CFRelease(version_parts);
|
||||
CFRelease(build);
|
||||
if (path == NULL)
|
||||
on_error("Unable to locate DeveloperDiskImage.dmg. This probably means you don't have Xcode installed, you will need to launch the app manually and logging output will not be shown!");
|
||||
on_error(@"Unable to locate DeveloperDiskImage.dmg. This probably means you don't have Xcode installed, you will need to launch the app manually and logging output will not be shown!");
|
||||
|
||||
return path;
|
||||
}
|
||||
@@ -582,11 +597,11 @@ void mount_callback(CFDictionaryRef dict, int arg) {
|
||||
CFStringRef status = CFDictionaryGetValue(dict, CFSTR("Status"));
|
||||
|
||||
if (CFEqual(status, CFSTR("LookingUpImage"))) {
|
||||
printf("[ 0%%] Looking up developer disk image\n");
|
||||
NSLogOut(@"[ 0%%] Looking up developer disk image");
|
||||
} else if (CFEqual(status, CFSTR("CopyingImage"))) {
|
||||
printf("[ 30%%] Copying DeveloperDiskImage.dmg to device\n");
|
||||
NSLogOut(@"[ 30%%] Copying DeveloperDiskImage.dmg to device");
|
||||
} else if (CFEqual(status, CFSTR("MountingImage"))) {
|
||||
printf("[ 90%%] Mounting developer disk image\n");
|
||||
NSLogOut(@"[ 90%%] Mounting developer disk image");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -596,8 +611,8 @@ void mount_developer_image(AMDeviceRef device) {
|
||||
CFStringRef sig_path = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@.signature"), image_path);
|
||||
|
||||
if (verbose) {
|
||||
printf("Device support path: %s\n", CFStringGetCStringPtr(ds_path, CFStringGetSystemEncoding()));
|
||||
printf("Developer disk image: %s\n", CFStringGetCStringPtr(image_path, CFStringGetSystemEncoding()));
|
||||
NSLogOut(@"Device support path: %@", ds_path);
|
||||
NSLogOut(@"Developer disk image: %@", image_path);
|
||||
}
|
||||
CFRelease(ds_path);
|
||||
|
||||
@@ -615,11 +630,11 @@ void mount_developer_image(AMDeviceRef device) {
|
||||
|
||||
int result = AMDeviceMountImage(device, image_path, options, &mount_callback, 0);
|
||||
if (result == 0) {
|
||||
printf("[ 95%%] Developer disk image mounted successfully\n");
|
||||
NSLogOut(@"[ 95%%] Developer disk image mounted successfully");
|
||||
} else if (result == 0xe8000076 /* already mounted */) {
|
||||
printf("[ 95%%] Developer disk image already mounted\n");
|
||||
NSLogOut(@"[ 95%%] Developer disk image already mounted");
|
||||
} else {
|
||||
on_error("Unable to mount developer disk image. (%x)", result);
|
||||
on_error(@"Unable to mount developer disk image. (%x)", result);
|
||||
}
|
||||
|
||||
CFRelease(image_path);
|
||||
@@ -635,7 +650,7 @@ mach_error_t transfer_callback(CFDictionaryRef dict, int arg) {
|
||||
CFStringRef path = CFDictionaryGetValue(dict, CFSTR("Path"));
|
||||
|
||||
if ((last_path == NULL || !CFEqual(path, last_path)) && !CFStringHasSuffix(path, CFSTR(".ipa"))) {
|
||||
printf("[%3d%%] Copying %s to device\n", percent / 2, CFStringGetCStringPtr(path, kCFStringEncodingMacRoman));
|
||||
NSLogOut(@"[%3d%%] Copying %@ to device", percent / 2, path);
|
||||
}
|
||||
|
||||
if (last_path != NULL) {
|
||||
@@ -652,7 +667,7 @@ mach_error_t install_callback(CFDictionaryRef dict, int arg) {
|
||||
CFStringRef status = CFDictionaryGetValue(dict, CFSTR("Status"));
|
||||
CFNumberGetValue(CFDictionaryGetValue(dict, CFSTR("PercentComplete")), kCFNumberSInt32Type, &percent);
|
||||
|
||||
printf("[%3d%%] %s\n", (percent / 2) + 50, CFStringGetCStringPtr(status, kCFStringEncodingMacRoman));
|
||||
NSLogOut(@"[%3d%%] %@", (percent / 2) + 50, status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -703,7 +718,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);
|
||||
@@ -736,7 +754,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);
|
||||
@@ -779,26 +797,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, kCFStringEncodingASCII);
|
||||
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, kCFStringEncodingASCII);
|
||||
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, kCFStringEncodingASCII, 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");
|
||||
CFDataRef cmds_data = CFStringCreateExternalRepresentation(NULL, cmds, kCFStringEncodingUTF8, 0);
|
||||
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;
|
||||
@@ -816,9 +835,9 @@ 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");
|
||||
out = fopen([python_file_path UTF8String], "w");
|
||||
fwrite(CFDataGetBytePtr(pmodule_data), CFDataGetLength(pmodule_data), 1, out);
|
||||
fclose(out);
|
||||
|
||||
@@ -834,8 +853,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;
|
||||
@@ -847,7 +864,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.
|
||||
@@ -957,7 +974,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;
|
||||
@@ -1003,15 +1020,15 @@ void setup_lldb(AMDeviceRef device, CFURLRef url) {
|
||||
check_error(AMDeviceValidatePairing(device));
|
||||
check_error(AMDeviceStartSession(device));
|
||||
|
||||
printf("------ Debug phase ------\n");
|
||||
NSLogOut(@"------ Debug phase ------");
|
||||
|
||||
if(AMDeviceGetInterfaceType(device) == 2)
|
||||
{
|
||||
printf("Cannot debug %s over %s.\n", CFStringGetCStringPtr(device_full_name, CFStringGetSystemEncoding()), CFStringGetCStringPtr(device_interface_name, CFStringGetSystemEncoding()));
|
||||
NSLogOut(@"Cannot debug %@ over %@.", device_full_name, device_interface_name);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
printf("Starting debug of %s connected through %s...\n", CFStringGetCStringPtr(device_full_name, CFStringGetSystemEncoding()), CFStringGetCStringPtr(device_interface_name, CFStringGetSystemEncoding()));
|
||||
NSLogOut(@"Starting debug of %@ connected through %@...", device_full_name, device_interface_name);
|
||||
|
||||
mount_developer_image(device); // put debugserver on the device
|
||||
start_remote_debug_server(device); // start debugserver
|
||||
@@ -1019,8 +1036,8 @@ void setup_lldb(AMDeviceRef device, CFURLRef url) {
|
||||
|
||||
CFRelease(url);
|
||||
|
||||
printf("[100%%] Connecting to remote debug server\n");
|
||||
printf("-------------------------\n");
|
||||
NSLogOut(@"[100%%] Connecting to remote debug server");
|
||||
NSLogOut(@"-------------------------");
|
||||
|
||||
setpgid(getpid(), 0);
|
||||
signal(SIGHUP, killed);
|
||||
@@ -1051,12 +1068,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");
|
||||
|
||||
@@ -1070,7 +1090,7 @@ void launch_debugger(AMDeviceRef device, CFURLRef url) {
|
||||
} else if (pid > 0) {
|
||||
child = pid;
|
||||
} else {
|
||||
on_sys_error("Fork failed");
|
||||
on_sys_error(@"Fork failed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1088,12 +1108,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");
|
||||
|
||||
@@ -1106,9 +1128,9 @@ void launch_debugger_and_exit(AMDeviceRef device, CFURLRef url) {
|
||||
} else if (pid > 0) {
|
||||
child = pid;
|
||||
if (verbose)
|
||||
printf("Waiting for child [Child: %d][Parent: %d]\n", child, parent);
|
||||
NSLogOut(@"Waiting for child [Child: %d][Parent: %d]\n", child, parent);
|
||||
} else {
|
||||
on_sys_error("Fork failed");
|
||||
on_sys_error(@"Fork failed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1160,8 +1182,6 @@ void read_dir(service_conn_t afcFd, afc_connection* afc_conn_p, const char* dir,
|
||||
AFCConnectionOpen(afcFd, 0, &afc_conn_p);
|
||||
}
|
||||
|
||||
printf("%s\n", dir);
|
||||
|
||||
afc_dictionary* afc_dict_p;
|
||||
char *key, *val;
|
||||
int not_dir = 0;
|
||||
@@ -1179,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);
|
||||
@@ -1227,15 +1253,13 @@ service_conn_t start_house_arrest_service(AMDeviceRef device) {
|
||||
service_conn_t houseFd;
|
||||
|
||||
if (bundle_id == NULL) {
|
||||
printf("Bundle id is not specified\n");
|
||||
exit(1);
|
||||
on_error(@"Bundle id is not specified");
|
||||
}
|
||||
|
||||
CFStringRef cf_bundle_id = CFStringCreateWithCString(NULL, bundle_id, kCFStringEncodingASCII);
|
||||
CFStringRef cf_bundle_id = CFStringCreateWithCString(NULL, bundle_id, kCFStringEncodingUTF8);
|
||||
if (AMDeviceStartHouseArrestService(device, cf_bundle_id, 0, &houseFd, 0) != 0)
|
||||
{
|
||||
printf("Unable to find bundle with id: %s\n", bundle_id);
|
||||
exit(1);
|
||||
on_error(@"Unable to find bundle with id: %@", bundle_id);
|
||||
}
|
||||
|
||||
check_error(AMDeviceStopSession(device));
|
||||
@@ -1273,7 +1297,7 @@ void* read_file_to_memory(char * path, size_t* file_size)
|
||||
*file_size = buf.st_size;
|
||||
FILE* fd = fopen(path, "r");
|
||||
char* content = malloc(*file_size);
|
||||
if (fread(content, *file_size, 1, fd) != 1)
|
||||
if (*file_size != 0 && fread(content, *file_size, 1, fd) != 1)
|
||||
{
|
||||
fclose(fd);
|
||||
return NULL;
|
||||
@@ -1296,7 +1320,7 @@ void list_files(AMDeviceRef device)
|
||||
int app_exists(AMDeviceRef device)
|
||||
{
|
||||
if (bundle_id == NULL) {
|
||||
printf("Bundle id is not specified\n");
|
||||
NSLogOut(@"Bundle id is not specified.");
|
||||
return 1;
|
||||
}
|
||||
AMDeviceConnect(device);
|
||||
@@ -1304,7 +1328,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"];
|
||||
@@ -1312,9 +1336,8 @@ int app_exists(AMDeviceRef device)
|
||||
CFDictionaryRef result = nil;
|
||||
check_error(AMDeviceLookupApplications(device, options, &result));
|
||||
|
||||
CFDictionaryRef app_dict = CFDictionaryGetValue(result, cf_bundle_id);
|
||||
bool appExists = (app_dict == NULL) ? false : true;
|
||||
printf("%s", appExists ? "true\n" : "false\n");
|
||||
bool appExists = CFDictionaryContainsKey(result, cf_bundle_id);
|
||||
NSLogOut(@"%@", appExists ? @"true" : @"false");
|
||||
CFRelease(cf_bundle_id);
|
||||
|
||||
check_error(AMDeviceStopSession(device));
|
||||
@@ -1324,6 +1347,31 @@ int app_exists(AMDeviceRef device)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void list_bundle_id(AMDeviceRef device)
|
||||
{
|
||||
AMDeviceConnect(device);
|
||||
assert(AMDeviceIsPaired(device));
|
||||
check_error(AMDeviceValidatePairing(device));
|
||||
check_error(AMDeviceStartSession(device));
|
||||
|
||||
NSArray *a = [NSArray arrayWithObjects:@"CFBundleIdentifier", nil];
|
||||
NSDictionary *optionsDict = [NSDictionary dictionaryWithObject:a forKey:@"ReturnAttributes"];
|
||||
CFDictionaryRef options = (CFDictionaryRef)optionsDict;
|
||||
CFDictionaryRef result = nil;
|
||||
check_error(AMDeviceLookupApplications(device, options, &result));
|
||||
|
||||
CFIndex count;
|
||||
count = CFDictionaryGetCount(result);
|
||||
const void *keys[count];
|
||||
CFDictionaryGetKeysAndValues(result, keys, NULL);
|
||||
for(int i = 0; i < count; ++i) {
|
||||
NSLogOut(@"%@", (CFStringRef)keys[i]);
|
||||
}
|
||||
|
||||
check_error(AMDeviceStopSession(device));
|
||||
check_error(AMDeviceDisconnect(device));
|
||||
}
|
||||
|
||||
void copy_file_callback(afc_connection* afc_conn_p, const char *name,int file)
|
||||
{
|
||||
const char *local_name=name;
|
||||
@@ -1365,38 +1413,23 @@ void copy_file_callback(afc_connection* afc_conn_p, const char *name,int file)
|
||||
}
|
||||
}
|
||||
|
||||
void mkdirhier(char *path)
|
||||
{
|
||||
char *slash;
|
||||
struct stat buf;
|
||||
|
||||
if (path[0]=='.' && path[1]=='/') path+=2;
|
||||
|
||||
if ((slash = strrchr(path,'/'))) {
|
||||
*slash = '\0';
|
||||
if (stat(path,&buf)==0) {
|
||||
*slash = '/';
|
||||
return;
|
||||
}
|
||||
mkdirhier(path);
|
||||
mkdir (path,0777);
|
||||
*slash = '/';
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void download_tree(AMDeviceRef device)
|
||||
{
|
||||
service_conn_t houseFd = start_house_arrest_service(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]);
|
||||
|
||||
if (AFCConnectionOpen(houseFd, 0, &afc_conn_p) == 0) do {
|
||||
|
||||
if (target_filename) {
|
||||
dirname = strdup(target_filename);
|
||||
mkdirhier(dirname);
|
||||
mkdirp(@(dirname));
|
||||
if (mkdir(dirname,0777) && errno!=EEXIST) {
|
||||
fprintf(stderr,"mkdir(\"%s\") failed: %s\n",dirname,strerror(errno));
|
||||
break;
|
||||
@@ -1407,7 +1440,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);
|
||||
|
||||
@@ -1436,8 +1469,7 @@ void upload_file(AMDeviceRef device) {
|
||||
|
||||
if (!file_content)
|
||||
{
|
||||
printf("Could not open file: %s\n", upload_pathname);
|
||||
exit(-1);
|
||||
on_error(@"Could not open file: %@", upload_pathname);
|
||||
}
|
||||
|
||||
// Make sure the directory was created
|
||||
@@ -1457,12 +1489,10 @@ void upload_file(AMDeviceRef device) {
|
||||
|
||||
int ret = AFCFileRefOpen(afc_conn_p, target_filename, 3, &file_ref);
|
||||
if (ret == 0x000a) {
|
||||
printf("Cannot write to %s. Permission error.\n", target_filename);
|
||||
exit(1);
|
||||
on_error(@"Cannot write to %@. Permission error.", [NSString stringWithUTF8String:target_filename]);
|
||||
}
|
||||
if (ret == 0x0009) {
|
||||
printf("Target %s is a directory.\n", target_filename);
|
||||
exit(1);
|
||||
on_error(@"Target %@ is a directory.", [NSString stringWithUTF8String:target_filename]);
|
||||
}
|
||||
assert(ret == 0);
|
||||
assert(AFCFileRefWrite(afc_conn_p, file_ref, file_content, file_size) == 0);
|
||||
@@ -1475,8 +1505,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);
|
||||
@@ -1488,8 +1516,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);
|
||||
@@ -1502,20 +1528,19 @@ void remove_path(AMDeviceRef device) {
|
||||
void uninstall_app(AMDeviceRef device) {
|
||||
CFRetain(device); // don't know if this is necessary?
|
||||
|
||||
printf("------ Uninstall phase ------\n");
|
||||
NSLogOut(@"------ Uninstall phase ------");
|
||||
|
||||
//Do we already have the bundle_id passed in via the command line? if so, use it.
|
||||
CFStringRef cf_uninstall_bundle_id = NULL;
|
||||
if (bundle_id != NULL)
|
||||
{
|
||||
cf_uninstall_bundle_id = CFStringCreateWithCString(NULL, bundle_id, kCFStringEncodingASCII);
|
||||
cf_uninstall_bundle_id = CFStringCreateWithCString(NULL, bundle_id, kCFStringEncodingUTF8);
|
||||
} else {
|
||||
printf ("Error: you need to pass in the bundle id, (i.e. --bundle_id com.my.app)");
|
||||
exit(1);
|
||||
on_error(@"Error: you need to pass in the bundle id, (i.e. --bundle_id com.my.app)");
|
||||
}
|
||||
|
||||
if (cf_uninstall_bundle_id == NULL) {
|
||||
printf("Error: Unable to get bundle id from user command or package %s\n Uninstall failed\n", app_path);
|
||||
on_error(@"Error: Unable to get bundle id from user command or package %@.\nUninstall failed.", app_path);
|
||||
} else {
|
||||
AMDeviceConnect(device);
|
||||
assert(AMDeviceIsPaired(device));
|
||||
@@ -1524,9 +1549,9 @@ void uninstall_app(AMDeviceRef device) {
|
||||
|
||||
int code = AMDeviceSecureUninstallApplication(0, device, cf_uninstall_bundle_id, 0, NULL, 0);
|
||||
if (code == 0) {
|
||||
printf("[ OK ] Uninstalled package with bundle id %s\n", CFStringGetCStringPtr(cf_uninstall_bundle_id, CFStringGetSystemEncoding()));
|
||||
NSLogOut(@"[ OK ] Uninstalled package with bundle id %@", cf_uninstall_bundle_id);
|
||||
} else {
|
||||
printf("[ ERROR ] Could not uninstall package with bundle id %s\n", CFStringGetCStringPtr(cf_uninstall_bundle_id, CFStringGetSystemEncoding()));
|
||||
on_error(@"[ ERROR ] Could not uninstall package with bundle id %@", cf_uninstall_bundle_id);
|
||||
}
|
||||
check_error(AMDeviceStopSession(device));
|
||||
check_error(AMDeviceDisconnect(device));
|
||||
@@ -1540,17 +1565,19 @@ void handle_device(AMDeviceRef device) {
|
||||
CFStringRef found_device_id = AMDeviceCopyDeviceIdentifier(device),
|
||||
device_full_name = get_device_full_name(device),
|
||||
device_interface_name = get_device_interface_name(device);
|
||||
|
||||
|
||||
if (detect_only) {
|
||||
printf("[....] Found %s connected through %s.\n", CFStringGetCStringPtr(device_full_name, CFStringGetSystemEncoding()), CFStringGetCStringPtr(device_interface_name, CFStringGetSystemEncoding()));
|
||||
NSLogOut(@"[....] Found %@ connected through %@.", device_full_name, device_interface_name);
|
||||
found_device = true;
|
||||
return;
|
||||
}
|
||||
if (device_id != NULL) {
|
||||
if(strcmp(device_id, CFStringGetCStringPtr(found_device_id, CFStringGetSystemEncoding())) == 0) {
|
||||
CFStringRef deviceCFSTR = CFStringCreateWithCString(NULL, device_id, kCFStringEncodingUTF8);
|
||||
if (CFStringCompare(deviceCFSTR, found_device_id, kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
|
||||
found_device = true;
|
||||
CFRelease(deviceCFSTR);
|
||||
} else {
|
||||
printf("Skipping %s.\n", CFStringGetCStringPtr(device_full_name, CFStringGetSystemEncoding()));
|
||||
NSLogOut(@"Skipping %@.", device_full_name);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -1558,7 +1585,7 @@ void handle_device(AMDeviceRef device) {
|
||||
found_device = true;
|
||||
}
|
||||
|
||||
printf("[....] Using %s (%s).\n", CFStringGetCStringPtr(device_full_name, CFStringGetSystemEncoding()), CFStringGetCStringPtr(found_device_id, CFStringGetSystemEncoding()));
|
||||
NSLogOut(@"[....] Using %@.", device_full_name);
|
||||
|
||||
if (command_only) {
|
||||
if (strcmp("list", command) == 0) {
|
||||
@@ -1566,7 +1593,7 @@ void handle_device(AMDeviceRef device) {
|
||||
} else if (strcmp("upload", command) == 0) {
|
||||
upload_file(device);
|
||||
} else if (strcmp("download", command) == 0) {
|
||||
download_tree(device);
|
||||
download_tree(device);
|
||||
} else if (strcmp("mkdir", command) == 0) {
|
||||
make_directory(device);
|
||||
} else if (strcmp("rm", command) == 0) {
|
||||
@@ -1575,6 +1602,8 @@ void handle_device(AMDeviceRef device) {
|
||||
exit(app_exists(device));
|
||||
} else if (strcmp("uninstall_only", command) == 0) {
|
||||
uninstall_app(device);
|
||||
} else if (strcmp("list_bundle_id", command) == 0) {
|
||||
list_bundle_id(device);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
@@ -1582,26 +1611,26 @@ 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);
|
||||
|
||||
CFRelease(relative_url);
|
||||
|
||||
if (uninstall) {
|
||||
printf("------ Uninstall phase ------\n");
|
||||
NSLogOut(@"------ Uninstall phase ------");
|
||||
|
||||
//Do we already have the bundle_id passed in via the command line? if so, use it.
|
||||
CFStringRef cf_uninstall_bundle_id = NULL;
|
||||
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);
|
||||
}
|
||||
|
||||
if (cf_uninstall_bundle_id == NULL) {
|
||||
printf("Error: Unable to get bundle id from user command or package %s\n Uninstall failed\n", app_path);
|
||||
on_error(@"Error: Unable to get bundle id from user command or package %@.\nUninstall failed.", app_path);
|
||||
} else {
|
||||
AMDeviceConnect(device);
|
||||
assert(AMDeviceIsPaired(device));
|
||||
@@ -1610,9 +1639,9 @@ void handle_device(AMDeviceRef device) {
|
||||
|
||||
int code = AMDeviceSecureUninstallApplication(0, device, cf_uninstall_bundle_id, 0, NULL, 0);
|
||||
if (code == 0) {
|
||||
printf("[ OK ] Uninstalled package with bundle id %s\n", CFStringGetCStringPtr(cf_uninstall_bundle_id, CFStringGetSystemEncoding()));
|
||||
NSLogOut(@"[ OK ] Uninstalled package with bundle id %@", cf_uninstall_bundle_id);
|
||||
} else {
|
||||
printf("[ ERROR ] Could not uninstall package with bundle id %s\n", CFStringGetCStringPtr(cf_uninstall_bundle_id, CFStringGetSystemEncoding()));
|
||||
on_error(@"[ ERROR ] Could not uninstall package with bundle id %@", cf_uninstall_bundle_id);
|
||||
}
|
||||
check_error(AMDeviceStopSession(device));
|
||||
check_error(AMDeviceDisconnect(device));
|
||||
@@ -1620,8 +1649,8 @@ void handle_device(AMDeviceRef device) {
|
||||
}
|
||||
|
||||
if(install) {
|
||||
printf("------ Install phase ------\n");
|
||||
printf("[ 0%%] Found %s connected through %s, beginning install\n", CFStringGetCStringPtr(device_full_name, CFStringGetSystemEncoding()), CFStringGetCStringPtr(device_interface_name, CFStringGetSystemEncoding()));
|
||||
NSLogOut(@"------ Install phase ------");
|
||||
NSLogOut(@"[ 0%%] Found %@ connected through %@, beginning install", device_full_name, device_interface_name);
|
||||
|
||||
AMDeviceConnect(device);
|
||||
assert(AMDeviceIsPaired(device));
|
||||
@@ -1669,7 +1698,7 @@ void handle_device(AMDeviceRef device) {
|
||||
CFRelease(path);
|
||||
CFRelease(options);
|
||||
|
||||
printf("[100%%] Installed package %s\n", app_path);
|
||||
NSLogOut(@"[100%%] Installed package %@", [NSString stringWithUTF8String:app_path]);
|
||||
}
|
||||
|
||||
if (!debug)
|
||||
@@ -1685,7 +1714,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);
|
||||
@@ -1705,12 +1735,12 @@ void timeout_callback(CFRunLoopTimerRef timer, void *info) {
|
||||
}
|
||||
|
||||
if(!found_device)
|
||||
on_error("Timed out waiting for device.");
|
||||
on_error(@"Timed out waiting for device.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!debug) {
|
||||
printf("[....] No more devices found.\n");
|
||||
NSLogOut(@"[....] No more devices found.");
|
||||
}
|
||||
|
||||
if (detect_only && !found_device) {
|
||||
@@ -1722,7 +1752,7 @@ void timeout_callback(CFRunLoopTimerRef timer, void *info) {
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
printf("Timeout. Killing child (%d) tree\n", child);
|
||||
NSLogOut(@"Timeout. Killing child (%d) tree.", child);
|
||||
}
|
||||
kill_ptree(child, SIGHUP);
|
||||
}
|
||||
@@ -1732,40 +1762,48 @@ void timeout_callback(CFRunLoopTimerRef timer, void *info) {
|
||||
}
|
||||
|
||||
void usage(const char* app) {
|
||||
printf(
|
||||
"Usage: %s [OPTION]...\n"
|
||||
" -d, --debug launch the app in lldb after installation\n"
|
||||
" -i, --id <device_id> the id of the device to connect to\n"
|
||||
" -c, --detect only detect if the device is connected\n"
|
||||
" -b, --bundle <bundle.app> the path to the app bundle to be installed\n"
|
||||
" -a, --args <args> command line arguments to pass to the app when launching it\n"
|
||||
" -t, --timeout <timeout> number of seconds to wait for a device to be connected\n"
|
||||
" -u, --unbuffered don't buffer stdout\n"
|
||||
" -n, --nostart do not start the app when debugging\n"
|
||||
" -I, --noninteractive start in non interactive mode (quit when app crashes or exits)\n"
|
||||
" -L, --justlaunch just launch the app and exit lldb\n"
|
||||
" -v, --verbose enable verbose output\n"
|
||||
" -m, --noinstall directly start debugging without app install (-d not required)\n"
|
||||
" -p, --port <number> port used for device, default: dynamic\n"
|
||||
" -r, --uninstall uninstall the app before install (do not use with -m; app cache and data are cleared) \n"
|
||||
" -9, --uninstall_only uninstall the app ONLY. Use only with -1 <bundle_id> \n"
|
||||
" -1, --bundle_id <bundle id> specify bundle id for list and upload\n"
|
||||
" -l, --list list files\n"
|
||||
" -o, --upload <file> upload file\n"
|
||||
" -w, --download download app tree\n"
|
||||
" -2, --to <target pathname> use together with up/download file/tree. specify target\n"
|
||||
" -D, --mkdir <dir> make directory on device\n"
|
||||
" -R, --rm <path> remove file or directory on device (directories must be empty)\n"
|
||||
" -V, --version print the executable version \n"
|
||||
" -e, --exists check if the app with given bundle_id is installed or not \n",
|
||||
app);
|
||||
NSLog(
|
||||
@"Usage: %@ [OPTION]...\n"
|
||||
@" -d, --debug launch the app in lldb after installation\n"
|
||||
@" -i, --id <device_id> the id of the device to connect to\n"
|
||||
@" -c, --detect only detect if the device is connected\n"
|
||||
@" -b, --bundle <bundle.app> the path to the app bundle to be installed\n"
|
||||
@" -a, --args <args> command line arguments to pass to the app when launching it\n"
|
||||
@" -t, --timeout <timeout> number of seconds to wait for a device to be connected\n"
|
||||
@" -u, --unbuffered don't buffer stdout\n"
|
||||
@" -n, --nostart do not start the app when debugging\n"
|
||||
@" -I, --noninteractive start in non interactive mode (quit when app crashes or exits)\n"
|
||||
@" -L, --justlaunch just launch the app and exit lldb\n"
|
||||
@" -v, --verbose enable verbose output\n"
|
||||
@" -m, --noinstall directly start debugging without app install (-d not required)\n"
|
||||
@" -p, --port <number> port used for device, default: dynamic\n"
|
||||
@" -r, --uninstall uninstall the app before install (do not use with -m; app cache and data are cleared) \n"
|
||||
@" -9, --uninstall_only uninstall the app ONLY. Use only with -1 <bundle_id> \n"
|
||||
@" -1, --bundle_id <bundle id> specify bundle id for list and upload\n"
|
||||
@" -l, --list list files\n"
|
||||
@" -o, --upload <file> upload file\n"
|
||||
@" -w, --download download app tree\n"
|
||||
@" -2, --to <target pathname> use together with up/download file/tree. specify target\n"
|
||||
@" -D, --mkdir <dir> make directory on device\n"
|
||||
@" -R, --rm <path> remove file or directory on device (directories must be empty)\n"
|
||||
@" -V, --version print the executable version \n"
|
||||
@" -e, --exists check if the app with given bundle_id is installed or not \n"
|
||||
@" -B, --list_bundle_id list bundle_id \n",
|
||||
[NSString stringWithUTF8String:app]);
|
||||
}
|
||||
|
||||
void show_version() {
|
||||
printf("%s\n", APP_VERSION);
|
||||
NSLogOut(@"%@", APP_VERSION);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
// 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' },
|
||||
@@ -1791,11 +1829,12 @@ int main(int argc, char *argv[]) {
|
||||
{ "mkdir", required_argument, NULL, 'D'},
|
||||
{ "rm", required_argument, NULL, 'R'},
|
||||
{ "exists", no_argument, NULL, 'e'},
|
||||
{ "list_bundle_id", no_argument, NULL, 'B'},
|
||||
{ NULL, 0, NULL, 0 },
|
||||
};
|
||||
char ch;
|
||||
|
||||
while ((ch = getopt_long(argc, argv, "VmcdvunrILeD:R:i:b:a:t:g:x:p:1:2:o:l::w::9::", longopts, NULL)) != -1)
|
||||
while ((ch = getopt_long(argc, argv, "VmcdvunrILeD:R:i:b:a:t:g:x:p:1:2:o:l::w::9::B::", longopts, NULL)) != -1)
|
||||
{
|
||||
switch (ch) {
|
||||
case 'm':
|
||||
@@ -1818,7 +1857,7 @@ int main(int argc, char *argv[]) {
|
||||
verbose = 1;
|
||||
break;
|
||||
case 't':
|
||||
timeout = atoi(optarg);
|
||||
_timeout = atoi(optarg);
|
||||
break;
|
||||
case 'u':
|
||||
unbuffered = 1;
|
||||
@@ -1828,10 +1867,12 @@ int main(int argc, char *argv[]) {
|
||||
break;
|
||||
case 'I':
|
||||
interactive = false;
|
||||
debug = 1;
|
||||
break;
|
||||
case 'L':
|
||||
interactive = false;
|
||||
justlaunch = true;
|
||||
debug = 1;
|
||||
break;
|
||||
case 'c':
|
||||
detect_only = true;
|
||||
@@ -1885,6 +1926,10 @@ int main(int argc, char *argv[]) {
|
||||
command_only = true;
|
||||
command = "exists";
|
||||
break;
|
||||
case 'B':
|
||||
command_only = true;
|
||||
command = "list_bundle_id";
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
return exitcode_error;
|
||||
@@ -1893,7 +1938,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
if (!app_path && !detect_only && !command_only) {
|
||||
usage(argv[0]);
|
||||
on_error("One of -[b|c|o|l|w|D|R|e|9] is required to proceed!");
|
||||
on_error(@"One of -[b|c|o|l|w|D|R|e|9] is required to proceed!");
|
||||
}
|
||||
|
||||
if (unbuffered) {
|
||||
@@ -1901,29 +1946,28 @@ 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) {
|
||||
if (access(app_path, F_OK) != 0) {
|
||||
on_sys_error("Can't access app path '%s'", app_path);
|
||||
on_sys_error(@"Can't access app path '%@'", [NSString stringWithUTF8String:app_path]);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
printf("[....] Waiting up to %d seconds for iOS device to be connected\n", timeout);
|
||||
NSLogOut(@"[....] Waiting up to %d seconds for iOS device to be connected", _timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("[....] Waiting for iOS device to be connected\n");
|
||||
NSLogOut(@"[....] Waiting for iOS device to be connected");
|
||||
}
|
||||
|
||||
struct am_device_notification *notify;
|
||||
AMDeviceNotificationSubscribe(&device_callback, 0, 0, NULL, ¬ify);
|
||||
CFRunLoopRun();
|
||||
}
|
||||
Reference in New Issue
Block a user