46 Commits
1.6.0 ... 1.7.0

Author SHA1 Message Date
Shazron Abdullah
6d61b7ca7c Fixes #83 - Enhancement to --justlaunch (implicit --debug) 2015-05-19 14:02:00 -07:00
Shazron Abdullah
590da67714 Fixes #84 - Enhancement to --noninteractive (implicit --debug) 2015-05-19 13:57:39 -07:00
Shazron Abdullah
8749a57936 Fixes #126 - --download option works incorrectly 2015-05-19 13:50:47 -07:00
Shazron Abdullah
3ba7403a39 Fixed crash in upload due to NSLogOut changes 2015-05-18 17:48:16 -07:00
Shazron Abdullah
84aeaad03b Fixed SIGSEV due to new NSLogOut changes. 2015-05-18 17:26:48 -07:00
Shazron Abdullah
ddcb4932ab Fixes #139 - stderr incorrect. Converted on_error, on_sys_log to use NSLog 2015-05-18 16:57:54 -07:00
Shazron Abdullah
11f1a89128 Added NSLogOut method. Same signature as NSLog, but logs to stdout instead of stderr. 2015-05-18 16:01:19 -07:00
Incont
c97b972172 fixed bug: Unable to load the empty file (closes #141) 2015-05-18 15:30:24 -07:00
Shazron Abdullah
1cb6110985 Added Roadmap to README 2015-05-18 14:22:55 -07:00
Shazron Abdullah
3dadb53b3b Revert version to 1.7.0 2015-05-18 13:53:47 -07:00
Shazron Abdullah
39aa232f97 Merge pull request #137 from mathworks/master
fixed the japanese issue
2015-05-18 12:41:03 -07:00
senthilm
609b635870 Merge https://github.com/phonegap/ios-deploy
manual merge and updated to 1.7.1
2015-05-17 07:56:29 -04:00
Shazron Abdullah
522f7bd667 Incremented version to 1.7.0 2015-05-17 01:03:24 -07:00
Shazron Abdullah
250794ce98 Added --list_bundle_id help text in README, added example 2015-05-17 01:03:04 -07:00
Shazron Abdullah
41eeedc472 Merge branch 'master' of https://github.com/Incont/ios-deploy 2015-05-17 00:54:47 -07:00
Shazron Abdullah
cdbe112ec6 Forgot to increment package.json 2015-05-17 00:50:33 -07:00
Incont
5377d9bec7 Merge remote-tracking branch 'phonegap/master' 2015-05-16 20:55:55 +03:00
Shazron Abdullah
5d2a0d5c8b Updated version to 1.6.3 2015-05-16 09:54:56 -07:00
Incont
e5fc979998 added options --list_bundle_id 2015-05-16 18:47:33 +03:00
Incont
18873b8340 small correction in app_exists 2015-05-16 18:07:27 +03:00
Shazron Abdullah
ed09a029de Fixes #132 - ios-deploy -c not listing devices with unicode characters 2015-05-15 17:05:46 -07:00
Shazron Abdullah
d65b94fa06 Updated version to 1.6.2 2015-05-15 15:44:59 -07:00
Shazron Abdullah
44b8068daa Fixes #134 - Better error reporting
Merge branch 'error-messages' of https://github.com/Unity-Technologies/ios-deploy
2015-05-15 13:04:17 -07:00
Incont
041d12e0b1 reverted return errorCode 2015-05-15 20:21:39 +03:00
Julius Trinkunas
8a3dbce11f More user friendly error messages. 2015-05-15 17:23:53 +03:00
Incont
9e45cc0edb fixed not working --exists 2015-05-15 14:05:27 +03:00
Julius Trinkunas
3857c9afc6 Unify error reporting. 2015-05-14 19:54:01 +03:00
Shazron Abdullah
125cd8de64 Updated version to 1.6.1 2015-05-13 11:01:16 -07:00
Shazron Abdullah
7070623432 Fixes #129 - "ios-deploy -c" never returns (partial revert of #122) 2015-05-13 11:00:56 -07:00
Shazron Abdullah
d712420e60 Fixes #118 - How to install without npm? 2015-05-12 15:38:03 -07:00
Shazron Abdullah
2c35b70ff7 Updated README for --uninstall_only from help text 2015-05-12 15:25:41 -07:00
Senthil Manickavasagam
a750efa382 Merge pull request #1 from senthilmanick/master
Updating to 1.5.3
2015-05-01 14:28:02 -04:00
Manickavasagam Senthil
0940a4d079 Fixed a segv happening in non english locale 2015-05-01 14:19:58 -04:00
Manickavasagam Senthil
b72d31b816 Fixed a segv happening in non english locale 2015-05-01 14:18:22 -04:00
Manickavasagam Senthil
5690b10635 merged with phonegap 2015-04-30 16:42:01 -04:00
senthil
d90171d8e7 updated to merge with phonegap 2015-04-11 14:40:49 -04:00
senthil
02c23792ee merged with version 1.5.0
Updated for devices that use japanese
Updated the version to 1.5.1
2015-04-11 14:18:54 -04:00
senthil
3e8a897fbc when just launch, if we get an empty packet, exit without an error 2015-01-29 18:06:07 -05:00
senthil
ba60ff6351 updated to version 1.3.6 2015-01-27 15:09:26 -05:00
senthil
134a0a5fd0 The return code must be < 128 otherwise treated as a signal 2015-01-27 15:07:44 -05:00
senthil
96e91eb269 merged with phonegap/ios-deploy 2015-01-20 17:36:45 -05:00
senthil
8577ef3411 sometimes the model is null in get_device_hardware_name; updated to
v1.3.4
2015-01-17 17:29:54 -05:00
senthil
99f401018d Using debug for -c as well 2014-12-06 20:24:48 -05:00
senthil
6ac084844e updated the version to 1.3.3 2014-11-17 10:08:42 -05:00
senthil
3dcd64f7c0 Merge with phonegap
Fixed the issue with implictly turning on debug for -c instead of -L
2014-11-17 10:06:48 -05:00
senthilmanick
12334f8ddf Merge pull request #2 from phonegap/master
Pull from phonegap
2014-11-17 10:03:14 -05:00
5 changed files with 627 additions and 214 deletions

View File

@@ -1,10 +1,10 @@
IOS_SDK_VERSION = 7.1
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
all: clean ios-deploy demo.app
demo.app: demo Info.plist
mkdir -p demo.app
@@ -32,4 +32,4 @@ debug: all
./ios-deploy --debug --bundle demo.app
clean:
rm -rf *.app demo ios-deploy
@rm -rf *.app demo ios-deploy

View File

@@ -4,20 +4,41 @@ 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.1
* You need to have a valid iOS development certificate installed.
* Xcode 6.1 should be installed
* Mac OS X. Tested on 10.10 Yosemite and iOS 8.3
* You need to have a valid iOS Development certificate installed.
* Xcode 6 or greater should be installed
## Roadmap
See our [milestones](https://github.com/phonegap/ios-deploy/milestones).
Significant changes:
1.8.0 will use an Xcode project instead of a Makefile (to prepare for 2.0.0)
2.0.0 will break out the commands into their own files, and create ios-deploy-lib for node.js use
## Installation
ios-deploy installation is made simple using the node.js package manager. If you use [Homebrew](http://brew.sh/), install node.js:
```bash
=======
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):
```
brew install node
```
Now install ios-deploy with the node.js package manager:
```bash
$ npm install -g ios-deploy
Now install ios-deploy with the [node.js](https://nodejs.org) package manager:
```
npm install -g ios-deploy
```
To install from source:
```
make install prefix=/usr/local
```
This will install ios-deploy in the `bin` folder of `/usr/local`, i.e. `/usr/local/bin`
## Usage
@@ -36,6 +57,7 @@ $ npm install -g ios-deploy
-m, --noinstall directly start debugging without app install (-d not required)
-p, --port <number> port used for device, default: 12345
-r, --uninstall uninstall the app before install (do not use with -m; app cache and data are cleared)
-9, --uninstall_only uninstall the app ONLY. Use only with -1 <bundle_id>
-1, --bundle_id <bundle id> specify bundle id for list, upload, and uninstall_only
-l, --list list files
-o, --upload <file> upload file
@@ -45,8 +67,7 @@ $ npm install -g ios-deploy
-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
-9, --uninstall_only uninstall an app only, by bundle_id
-B, --list_bundle_id list bundle_id
## Examples
@@ -84,12 +105,16 @@ The commands below assume that you have an app called `my.app` with bundle id `b
// Uninstall an app
ios-deploy --uninstall_only --bundle_id my.bundle.id
// list all bundle ids of all apps on your device
ios-deploy --list_bundle_id
## Demo
* The included demo.app represents the minimum required to get code running on iOS.
* `make install` will install demo.app to the device.
* `make debug` will install demo.app and launch a GDB session.
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 debug` will install demo.app and launch a LLDB session.
## Notes

358
errors.h Normal file
View File

@@ -0,0 +1,358 @@
typedef struct errorcode_to_id {
unsigned int error;
const char* id;
} errorcode_to_id_t;
typedef struct error_id_to_message {
const char* id;
const char* message;
} error_id_to_message_t;
// Taken from 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" },
{ 0xe8000003, "kAMDNoResourcesError" },
{ 0xe8000004, "kAMDReadError" },
{ 0xe8000005, "kAMDWriteError" },
{ 0xe8000006, "kAMDUnknownPacketError" },
{ 0xe8000007, "kAMDInvalidArgumentError" },
{ 0xe8000008, "kAMDNotFoundError" },
{ 0xe8000009, "kAMDIsDirectoryError" },
{ 0xe800000a, "kAMDPermissionError" },
{ 0xe800000b, "kAMDNotConnectedError" },
{ 0xe800000c, "kAMDTimeOutError" },
{ 0xe800000d, "kAMDOverrunError" },
{ 0xe800000e, "kAMDEOFError" },
{ 0xe800000f, "kAMDUnsupportedError" },
{ 0xe8000010, "kAMDFileExistsError" },
{ 0xe8000011, "kAMDBusyError" },
{ 0xe8000012, "kAMDCryptoError" },
{ 0xe8000013, "kAMDInvalidResponseError" },
{ 0xe8000014, "kAMDMissingKeyError" },
{ 0xe8000015, "kAMDMissingValueError" },
{ 0xe8000016, "kAMDGetProhibitedError" },
{ 0xe8000017, "kAMDSetProhibitedError" },
{ 0xe8000018, "kAMDRemoveProhibitedError" },
{ 0xe8000019, "kAMDImmutableValueError" },
{ 0xe800001a, "kAMDPasswordProtectedError" },
{ 0xe800001b, "kAMDMissingHostIDError" },
{ 0xe800001c, "kAMDInvalidHostIDError" },
{ 0xe800001d, "kAMDSessionActiveError" },
{ 0xe800001e, "kAMDSessionInactiveError" },
{ 0xe800001f, "kAMDMissingSessionIDError" },
{ 0xe8000020, "kAMDInvalidSessionIDError" },
{ 0xe8000021, "kAMDMissingServiceError" },
{ 0xe8000022, "kAMDInvalidServiceError" },
{ 0xe8000023, "kAMDInvalidCheckinError" },
{ 0xe8000024, "kAMDCheckinTimeoutError" },
{ 0xe8000025, "kAMDMissingPairRecordError" },
{ 0xe8000026, "kAMDInvalidActivationRecordError" },
{ 0xe8000027, "kAMDMissingActivationRecordError" },
{ 0xe8000028, "kAMDWrongDroidError" },
{ 0xe8000029, "kAMDSUVerificationError" },
{ 0xe800002a, "kAMDSUPatchError" },
{ 0xe800002b, "kAMDSUFirmwareError" },
{ 0xe800002c, "kAMDProvisioningProfileNotValid" },
{ 0xe800002d, "kAMDSendMessageError" },
{ 0xe800002e, "kAMDReceiveMessageError" },
{ 0xe800002f, "kAMDMissingOptionsError" },
{ 0xe8000030, "kAMDMissingImageTypeError" },
{ 0xe8000031, "kAMDDigestFailedError" },
{ 0xe8000032, "kAMDStartServiceError" },
{ 0xe8000033, "kAMDInvalidDiskImageError" },
{ 0xe8000034, "kAMDMissingDigestError" },
{ 0xe8000035, "kAMDMuxError" },
{ 0xe8000036, "kAMDApplicationAlreadyInstalledError" },
{ 0xe8000037, "kAMDApplicationMoveFailedError" },
{ 0xe8000038, "kAMDApplicationSINFCaptureFailedError" },
{ 0xe8000039, "kAMDApplicationSandboxFailedError" },
{ 0xe800003a, "kAMDApplicationVerificationFailedError" },
{ 0xe800003b, "kAMDArchiveDestructionFailedError" },
{ 0xe800003c, "kAMDBundleVerificationFailedError" },
{ 0xe800003d, "kAMDCarrierBundleCopyFailedError" },
{ 0xe800003e, "kAMDCarrierBundleDirectoryCreationFailedError" },
{ 0xe800003f, "kAMDCarrierBundleMissingSupportedSIMsError" },
{ 0xe8000040, "kAMDCommCenterNotificationFailedError" },
{ 0xe8000041, "kAMDContainerCreationFailedError" },
{ 0xe8000042, "kAMDContainerP0wnFailedError" },
{ 0xe8000043, "kAMDContainerRemovalFailedError" },
{ 0xe8000044, "kAMDEmbeddedProfileInstallFailedError" },
{ 0xe8000045, "kAMDErrorError" },
{ 0xe8000046, "kAMDExecutableTwiddleFailedError" },
{ 0xe8000047, "kAMDExistenceCheckFailedError" },
{ 0xe8000048, "kAMDInstallMapUpdateFailedError" },
{ 0xe8000049, "kAMDManifestCaptureFailedError" },
{ 0xe800004a, "kAMDMapGenerationFailedError" },
{ 0xe800004b, "kAMDMissingBundleExecutableError" },
{ 0xe800004c, "kAMDMissingBundleIdentifierError" },
{ 0xe800004d, "kAMDMissingBundlePathError" },
{ 0xe800004e, "kAMDMissingContainerError" },
{ 0xe800004f, "kAMDNotificationFailedError" },
{ 0xe8000050, "kAMDPackageExtractionFailedError" },
{ 0xe8000051, "kAMDPackageInspectionFailedError" },
{ 0xe8000052, "kAMDPackageMoveFailedError" },
{ 0xe8000053, "kAMDPathConversionFailedError" },
{ 0xe8000054, "kAMDRestoreContainerFailedError" },
{ 0xe8000055, "kAMDSeatbeltProfileRemovalFailedError" },
{ 0xe8000056, "kAMDStageCreationFailedError" },
{ 0xe8000057, "kAMDSymlinkFailedError" },
{ 0xe8000058, "kAMDiTunesArtworkCaptureFailedError" },
{ 0xe8000059, "kAMDiTunesMetadataCaptureFailedError" },
{ 0xe800005a, "kAMDAlreadyArchivedError" },
{ 0xe800005b, "kAMDServiceLimitError" },
{ 0xe800005c, "kAMDInvalidPairRecordError" },
{ 0xe800005d, "kAMDServiceProhibitedError" },
{ 0xe800005e, "kAMDCheckinSetupFailedError" },
{ 0xe800005f, "kAMDCheckinConnectionFailedError" },
{ 0xe8000060, "kAMDCheckinReceiveFailedError" },
{ 0xe8000061, "kAMDCheckinResponseFailedError" },
{ 0xe8000062, "kAMDCheckinSendFailedError" },
{ 0xe8000063, "kAMDMuxCreateListenerError" },
{ 0xe8000064, "kAMDMuxGetListenerError" },
{ 0xe8000065, "kAMDMuxConnectError" },
{ 0xe8000066, "kAMDUnknownCommandError" },
{ 0xe8000067, "kAMDAPIInternalError" },
{ 0xe8000068, "kAMDSavePairRecordFailedError" },
{ 0xe8000069, "kAMDCheckinOutOfMemoryError" },
{ 0xe800006a, "kAMDDeviceTooNewError" },
{ 0xe800006b, "kAMDDeviceRefNoGood" },
{ 0xe800006c, "kAMDCannotTranslateError" },
{ 0xe800006d, "kAMDMobileImageMounterMissingImageSignature" },
{ 0xe800006e, "kAMDMobileImageMounterResponseCreationFailed" },
{ 0xe800006f, "kAMDMobileImageMounterMissingImageType" },
{ 0xe8000070, "kAMDMobileImageMounterMissingImagePath" },
{ 0xe8000071, "kAMDMobileImageMounterImageMapLoadFailed" },
{ 0xe8000072, "kAMDMobileImageMounterAlreadyMounted" },
{ 0xe8000073, "kAMDMobileImageMounterImageMoveFailed" },
{ 0xe8000074, "kAMDMobileImageMounterMountPathMissing" },
{ 0xe8000075, "kAMDMobileImageMounterMountPathNotEmpty" },
{ 0xe8000076, "kAMDMobileImageMounterImageMountFailed" },
{ 0xe8000077, "kAMDMobileImageMounterTrustCacheLoadFailed" },
{ 0xe8000078, "kAMDMobileImageMounterDigestFailed" },
{ 0xe8000079, "kAMDMobileImageMounterDigestCreationFailed" },
{ 0xe800007a, "kAMDMobileImageMounterImageVerificationFailed" },
{ 0xe800007b, "kAMDMobileImageMounterImageInfoCreationFailed" },
{ 0xe800007c, "kAMDMobileImageMounterImageMapStoreFailed" },
{ 0xe800007d, "kAMDBonjourSetupError" },
{ 0xe800007e, "kAMDDeviceOSVersionTooLow" },
{ 0xe800007f, "kAMDNoWifiSyncSupportError" },
{ 0xe8000080, "kAMDDeviceFamilyNotSupported" },
{ 0xe8000081, "kAMDEscrowLockedError" },
{ 0xe8000082, "kAMDPairingProhibitedError" },
{ 0xe8000083, "kAMDProhibitedBySupervision" },
{ 0xe8000084, "kAMDDeviceDisconnectedError" },
{ 0xe8000085, "kAMDTooBigError" },
{ 0xe8000086, "kAMDPackagePatchFailedError" },
{ 0xe8000087, "kAMDIncorrectArchitectureError" },
{ 0xe8000088, "kAMDPluginCopyFailedError" },
{ 0xe8000089, "kAMDBreadcrumbFailedError" },
{ 0xe800008a, "kAMDBreadcrumbUnlockError" },
{ 0xe800008b, "kAMDGeoJSONCaptureFailedError" },
{ 0xe800008c, "kAMDNewsstandArtworkCaptureFailedError" },
{ 0xe800008d, "kAMDMissingCommandError" },
{ 0xe800008e, "kAMDNotEntitledError" },
{ 0xe800008f, "kAMDMissingPackagePathError" },
{ 0xe8000090, "kAMDMissingContainerPathError" },
{ 0xe8000091, "kAMDMissingApplicationIdentifierError" },
{ 0xe8000092, "kAMDMissingAttributeValueError" },
{ 0xe8000093, "kAMDLookupFailedError" },
{ 0xe8000094, "kAMDDictCreationFailedError" },
{ 0xe8000095, "kAMDUserDeniedPairingError" },
{ 0xe8000096, "kAMDPairingDialogResponsePendingError" },
{ 0xe8000097, "kAMDInstallProhibitedError" },
{ 0xe8000098, "kAMDUninstallProhibitedError" },
{ 0xe8000099, "kAMDFMiPProtectedError" },
{ 0xe800009a, "kAMDMCProtected" },
{ 0xe800009b, "kAMDMCChallengeRequired" },
{ 0xe800009c, "kAMDMissingBundleVersionError" },
{ 0xe8008015, "A valid provisioning profile for this executable was not found."},
};
const int errorcode_to_id_count = sizeof(errorcode_to_id) / sizeof(errorcode_to_id_t);
// Taken from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/Resources/en_GB.lproj/Localizable.strings
error_id_to_message_t error_id_to_message[] = {
{ "kAMDAPIInternalError", "There was an internal API error." },
{ "kAMDAlreadyArchivedError", "The application is already archived." },
{ "kAMDAppBlacklistedError", "This app is not allowed to be installed on this device." },
{ "kAMDApplicationAlreadyInstalledError", "A system application with the given bundle identifier is already installed on the device and cannot be replaced." },
{ "kAMDApplicationMoveFailedError", "The application could not be moved into place on the device." },
{ "kAMDApplicationSandboxFailedError", "The application could not be sandboxed." },
{ "kAMDApplicationVerificationFailedError", "The application could not be verified." },
{ "kAMDArchiveDestructionFailedError", "Could not remove the application archive." },
{ "kAMDBadHeaderError", "Could not transfer file." },
{ "kAMDBreadcrumbFailedError", "Could not write installation breadcrumb." },
{ "kAMDBreadcrumbUnlockError", "Could not update installation breadcrumb." },
{ "kAMDBundleVerificationFailedError", "The carrier bundle could not be verified." },
{ "kAMDBusyError", "The device is busy." },
{ "kAMDCannotTranslateError", "Could not translate messages from device" },
{ "kAMDCarrierBundleCopyFailedError", "Could not install the carrier bundle." },
{ "kAMDCarrierBundleDirectoryCreationFailedError", "Could not create the carrier bundle directory." },
{ "kAMDCarrierBundleMissingSupportedSIMsError", "There are no supported SIMs for this carrier bundle." },
{ "kAMDCheckinConnectionFailedError", "The service did not start properly on the device." },
{ "kAMDCheckinOutOfMemoryError", "The service did not start properly on the device." },
{ "kAMDCheckinReceiveFailedError", "The service did not start properly on the device." },
{ "kAMDCheckinResponseFailedError", "The service did not start properly on the device." },
{ "kAMDCheckinSendFailedError", "The service did not start properly on the device." },
{ "kAMDCheckinSetupFailedError", "Could not start service on device" },
{ "kAMDCheckinTimeoutError", "The service did not start properly on the device." },
{ "kAMDCommCenterNotificationFailedError", "Could not listen for notification from the baseband." },
{ "kAMDContainerCreationFailedError", "Could not create application container." },
{ "kAMDContainerP0wnFailedError", "Could not repair permissions on application container." },
{ "kAMDContainerRemovalFailedError", "Could not remove the application container." },
{ "kAMDCryptoError", "Could not establish a secure connection to the device." },
{ "kAMDDeviceDisconnectedError", "This device is no longer connected." },
{ "kAMDDeviceFamilyNotSupported", "This application does not support this kind of device." },
{ "kAMDDeviceOSVersionTooLow", "The device OS version is too low." },
{ "kAMDDeviceRefNoGood", "This device is no longer connected." },
{ "kAMDDeviceTooNewError", "This application needs to be updated." },
{ "kAMDDictCreationFailedError", "Could not extract capabilities from the request." },
{ "kAMDDigestFailedError", "Could not read disk image." },
{ "kAMDEOFError", "End of file." },
{ "kAMDEmbeddedProfileInstallFailedError", "Could not install the embedded provisioning profile." },
{ "kAMDErrorError", "An error occurred." },
{ "kAMDEscrowLockedError", "Device is not available until first unlock after boot." },
{ "kAMDExecutableTwiddleFailedError", "Could not change executable permissions on the application." },
{ "kAMDExistenceCheckFailedError", "Could not check to see if the application already exists." },
{ "kAMDFMiPProtectedError", "The device is in lost mode." },
{ "kAMDFileExistsError", "The file already exists." },
{ "kAMDGeoJSONCaptureFailedError", "Could not save the GeoJSON data." },
{ "kAMDGetProhibitedError", "Cannot retrieve value from the passcode-locked device." },
{ "kAMDImmutableValueError", "This value cannot be changed." },
{ "kAMDIncorrectArchitectureError", "This application does not support this device's CPU type." },
{ "kAMDInstallMapUpdateFailedError", "Could not update the installed applications list." },
{ "kAMDInstallProhibitedError", "Installation of apps is prohibited by a policy on the device." },
{ "kAMDInvalidActivationRecordError", "The activation record is not valid." },
{ "kAMDInvalidArgumentError", "The argument is invalid." },
{ "kAMDInvalidCheckinError", "Could not start service on device" },
{ "kAMDInvalidDiskImageError", "The disk image is invalid." },
{ "kAMDInvalidHostIDError", "The device does not recognise this host." },
{ "kAMDInvalidPairRecordError", "The host is no longer paired with the device." },
{ "kAMDInvalidResponseError", "Received an unexpected response from the device." },
{ "kAMDInvalidServiceError", "The service is invalid." },
{ "kAMDInvalidSessionIDError", "The session ID is invalid." },
{ "kAMDIsDirectoryError", "The path is a directory." },
{ "kAMDLookupFailedError", "Could not list installed applications." },
{ "kAMDMCChallengeRequired", "A policy on the device requires secure pairing." },
{ "kAMDMCProtected", "Pairing is prohibited by a policy on the device." },
{ "kAMDManifestCaptureFailedError", "Could not save the application manifest." },
{ "kAMDMapGenerationFailedError", "Could not generate the map." },
{ "kAMDMissingActivationRecordError", "The activation record could not be found." },
{ "kAMDMissingApplicationIdentifierError", "Request was missing the application identifier." },
{ "kAMDMissingAttributeValueError", "Request was missing a required value." },
{ "kAMDMissingBundleExecutableError", "The application bundle does not contain an executable." },
{ "kAMDMissingBundleIdentifierError", "The application bundle does not contain a valid identifier." },
{ "kAMDMissingBundlePathError", "Could not determine the application bundle path." },
{ "kAMDMissingBundleVersionError", "The bundle's Info.plist does not contain a CFBundleVersion key or its value is not a string." },
{ "kAMDMissingCommandError", "The request did not contain a command." },
{ "kAMDMissingContainerError", "Could not find the container for the installed application." },
{ "kAMDMissingContainerPathError", "Request was missing the container path." },
{ "kAMDMissingDigestError", "The digest is missing." },
{ "kAMDMissingHostIDError", "The device does not recognise this host." },
{ "kAMDMissingImageTypeError", "The image is missing." },
{ "kAMDMissingKeyError", "The key is missing." },
{ "kAMDMissingOptionsError", "The options are missing." },
{ "kAMDMissingPackagePathError", "Request was missing the package path." },
{ "kAMDMissingPairRecordError", "The host is not paired with the device." },
{ "kAMDMissingServiceError", "The service is missing." },
{ "kAMDMissingSessionIDError", "The session ID is missing." },
{ "kAMDMissingValueError", "The value is missing." },
{ "kAMDMobileImageMounterAlreadyMounted", "Could not support development." },
{ "kAMDMobileImageMounterDigestCreationFailed", "Could not support development." },
{ "kAMDMobileImageMounterDigestFailed", "Could not support development." },
{ "kAMDMobileImageMounterImageInfoCreationFailed", "Could not support development." },
{ "kAMDMobileImageMounterImageMapLoadFailed", "Could not support development." },
{ "kAMDMobileImageMounterImageMapStoreFailed", "Could not support development." },
{ "kAMDMobileImageMounterImageMountFailed", "Could not support development." },
{ "kAMDMobileImageMounterImageMoveFailed", "Could not support development." },
{ "kAMDMobileImageMounterImageVerificationFailed", "Could not support development." },
{ "kAMDMobileImageMounterMissingImagePath", "Could not support development." },
{ "kAMDMobileImageMounterMissingImageSignature", "Could not support development." },
{ "kAMDMobileImageMounterMissingImageType", "Could not support development." },
{ "kAMDMobileImageMounterMountPathMissing", "Could not support development." },
{ "kAMDMobileImageMounterMountPathNotEmpty", "Could not support development." },
{ "kAMDMobileImageMounterResponseCreationFailed", "Could not support development." },
{ "kAMDMobileImageMounterTrustCacheLoadFailed", "Could not support development." },
{ "kAMDMuxConnectError", "Could not connect to the device." },
{ "kAMDMuxCreateListenerError", "Could not listen for USB devices." },
{ "kAMDMuxError", "There was an error with the USB device multiplexor." },
{ "kAMDMuxGetListenerError", "Could not get the USB listener." },
{ "kAMDNewsstandArtworkCaptureFailedError", "Could not save the Newsstand artwork." },
{ "kAMDNoResourcesError", "Could not allocate a resource." },
{ "kAMDNoWifiSyncSupportError", "Device doesn't support wireless sync." },
{ "kAMDNotConnectedError", "Not connected to the device." },
{ "kAMDNotEntitledError", "The requesting application is not allowed to make this request." },
{ "kAMDNotFoundError", "The file could not be found." },
{ "kAMDNotificationFailedError", "Could not post a notification." },
{ "kAMDOverrunError", "There was a buffer overrun." },
{ "kAMDPackageExtractionFailedError", "Could not open the application package." },
{ "kAMDPackageInspectionFailedError", "Could not inspect the application package." },
{ "kAMDPackageMoveFailedError", "Could not move the application package into the staging location." },
{ "kAMDPackagePatchFailedError", "Could not apply patch update to application." },
{ "kAMDPairingDialogResponsePendingError", "The user has not yet responded to the pairing request." },
{ "kAMDPairingProhibitedError", "Pairing only allowed over USB." },
{ "kAMDPasswordProtectedError", "The device is passcode protected." },
{ "kAMDPathConversionFailedError", "Could not convert the path." },
{ "kAMDPermissionError", "You do not have permission." },
{ "kAMDPluginCopyFailedError", "Could not copy VPN Plug-in into app container." },
{ "kAMDProhibitedBySupervision", "Operation prohibited on supervised devices." },
{ "kAMDProvisioningProfileNotValid", "The provisioning profile is not valid." },
{ "kAMDReadError", "Could not read from the device." },
{ "kAMDReceiveMessageError", "Could not receive a message from the device." },
{ "kAMDRemoveProhibitedError", "Cannot remove value on device." },
{ "kAMDRestoreContainerFailedError", "Could not restore the application container." },
{ "kAMDSUFirmwareError", "Could not flash the firmware." },
{ "kAMDSUPatchError", "Could not patch the file." },
{ "kAMDSUVerificationError", "The software update package could not be verified." },
{ "kAMDSavePairRecordFailedError", "Could not save the pairing record." },
{ "kAMDSeatbeltProfileRemovalFailedError", "Could not remove the application seatbelt profile." },
{ "kAMDSendMessageError", "Could not send a message to the device." },
{ "kAMDServiceLimitError", "Too many instances of this service are already running." },
{ "kAMDServiceProhibitedError", "The service could not be started on the device." },
{ "kAMDSessionActiveError", "The session is active." },
{ "kAMDSessionInactiveError", "The session is inactive." },
{ "kAMDSetProhibitedError", "Cannot set value on device." },
{ "kAMDStageCreationFailedError", "Could not create the staging directory." },
{ "kAMDStartServiceError", "The service could not be started." },
{ "kAMDSuccess", "There was no error." },
{ "kAMDSymlinkFailedError", "Could not create the symlink." },
{ "kAMDTimeOutError", "The operation timed out." },
{ "kAMDTooBigError", "The message is too big." },
{ "kAMDUndefinedError", "An unknown error occurred." },
{ "kAMDUninstallProhibitedError", "Uninstallation of apps is prohibited by a policy on the device." },
{ "kAMDUnknownCommandError", "The device does not recognise the command." },
{ "kAMDUnknownPacketError", "The packet is unknown." },
{ "kAMDUnsupportedError", "This operation is unsupported." },
{ "kAMDUserDeniedPairingError", "The device rejected the pairing attempt." },
{ "kAMDWriteError", "Could not write to the device." },
{ "kAMDWrongDroidError", "The device is in recovery mode." },
{ "kAMDiTunesArtworkCaptureFailedError", "Could not save the iTunes artwork." },
{ "kAMDiTunesMetadataCaptureFailedError", "Could not save the iTunes metadata." },
};
const int error_id_to_message_count = sizeof(error_id_to_message) / sizeof(error_id_to_message_t);
const char* get_error_message(unsigned int error) {
const char* id = NULL;
// Lookup error localization id
for (int i = 0; i < errorcode_to_id_count; i++) {
if (errorcode_to_id[i].error == error) {
id = errorcode_to_id[i].id;
break;
}
}
// Lookup error message
if (id) {
for (int i = 0; i < error_id_to_message_count; i++)
if (strcmp(error_id_to_message[i].id, id) == 0)
return error_id_to_message[i].message;
}
// If message is not found, then at least return id if it was found, otherwise NULL
return id;
};

View File

@@ -14,9 +14,11 @@
#include <pwd.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include "MobileDevice.h"
#define APP_VERSION "1.6.0"
#include "MobileDevice.h"
#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
/*
@@ -183,6 +185,51 @@ AMDeviceRef best_device_match = NULL;
const int exitcode_error = 253;
const int exitcode_app_crash = 254;
// Checks for MobileDevice.framework errors, tries to print them and exits.
#define check_error(call) \
do { \
unsigned int err = (unsigned int)call; \
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 ? [NSString stringWithUTF8String:msg] : @"unknown."); \
} \
} while (false);
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(NSString* format, ...) {
const char* errstr = strerror(errno);
va_list valist;
va_start(valist, format);
NSString* str = [[[NSString alloc] initWithFormat:format arguments:valist] autorelease];
va_end(valist);
on_error(@"%@ : %@", str, errstr);
}
void NSLogOut(NSString* format, ...) {
va_list valist;
va_start(valist, format);
NSString* str = [[[NSString alloc] initWithFormat:format arguments:valist] autorelease];
va_end(valist);
[[str stringByAppendingString:@"\n"] writeToFile:@"/dev/stdout" atomically:NO encoding:NSUTF8StringEncoding error:nil];
}
Boolean path_exists(CFTypeRef path) {
if (CFGetTypeID(path) == CFStringGetTypeID()) {
CFURLRef url = CFURLCreateWithFileSystemPath(NULL, path, kCFURLPOSIXPathStyle, true);
@@ -222,10 +269,7 @@ CFStringRef find_path(CFStringRef rootPath, CFStringRef namePattern, CFStringRef
CFRelease(cf_command);
if (!(fpipe = (FILE *)popen(command, "r")))
{
perror("Error encountered while opening pipe");
exit(exitcode_error);
}
on_sys_error(@"Error encountered while opening pipe");
char buffer[256] = { '\0' };
@@ -247,10 +291,7 @@ CFStringRef copy_xcode_dev_path() {
char *command = "xcode-select -print-path";
if (!(fpipe = (FILE *)popen(command, "r")))
{
perror("Error encountered while opening pipe");
exit(exitcode_error);
}
on_sys_error(@"Error encountered while opening pipe");
char buffer[256] = { '\0' };
@@ -413,18 +454,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)
@@ -503,10 +534,7 @@ CFStringRef copy_device_support_path(AMDeviceRef device) {
CFRelease(build);
if (path == NULL)
{
printf("[ !! ] Unable to locate DeviceSupport directory.\n[ !! ] This probably means you don't have Xcode installed, you will need to launch the app manually and logging output will not be shown!\n");
exit(exitcode_error);
}
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;
}
@@ -544,10 +572,7 @@ CFStringRef copy_developer_disk_image_path(AMDeviceRef device) {
CFRelease(version_parts);
CFRelease(build);
if (path == NULL)
{
printf("[ !! ] Unable to locate DeveloperDiskImage.dmg.\n[ !! ] This probably means you don't have Xcode installed, you will need to launch the app manually and logging output will not be shown!\n");
exit(exitcode_error);
}
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;
}
@@ -556,11 +581,11 @@ void mount_callback(CFDictionaryRef dict, int arg) {
CFStringRef status = CFDictionaryGetValue(dict, CFSTR("Status"));
if (CFEqual(status, CFSTR("LookingUpImage"))) {
printf("[ 0%%] Looking up developer disk image\n");
NSLogOut(@"[ 0%%] Looking up developer disk image");
} else if (CFEqual(status, CFSTR("CopyingImage"))) {
printf("[ 30%%] Copying DeveloperDiskImage.dmg to device\n");
NSLogOut(@"[ 30%%] Copying DeveloperDiskImage.dmg to device");
} else if (CFEqual(status, CFSTR("MountingImage"))) {
printf("[ 90%%] Mounting developer disk image\n");
NSLogOut(@"[ 90%%] Mounting developer disk image");
}
}
@@ -570,8 +595,8 @@ void mount_developer_image(AMDeviceRef device) {
CFStringRef sig_path = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@.signature"), image_path);
if (verbose) {
printf("Device support path: %s\n", CFStringGetCStringPtr(ds_path, CFStringGetSystemEncoding()));
printf("Developer disk image: %s\n", CFStringGetCStringPtr(image_path, CFStringGetSystemEncoding()));
NSLogOut(@"Device support path: %@", ds_path);
NSLogOut(@"Developer disk image: %@", image_path);
}
CFRelease(ds_path);
@@ -589,12 +614,11 @@ void mount_developer_image(AMDeviceRef device) {
int result = AMDeviceMountImage(device, image_path, options, &mount_callback, 0);
if (result == 0) {
printf("[ 95%%] Developer disk image mounted successfully\n");
NSLogOut(@"[ 95%%] Developer disk image mounted successfully");
} else if (result == 0xe8000076 /* already mounted */) {
printf("[ 95%%] Developer disk image already mounted\n");
NSLogOut(@"[ 95%%] Developer disk image already mounted");
} else {
printf("[ !! ] Unable to mount developer disk image. (%x)\n", result);
exit(exitcode_error);
on_error(@"Unable to mount developer disk image. (%x)", result);
}
CFRelease(image_path);
@@ -610,7 +634,7 @@ mach_error_t transfer_callback(CFDictionaryRef dict, int arg) {
CFStringRef path = CFDictionaryGetValue(dict, CFSTR("Path"));
if ((last_path == NULL || !CFEqual(path, last_path)) && !CFStringHasSuffix(path, CFSTR(".ipa"))) {
printf("[%3d%%] Copying %s to device\n", percent / 2, CFStringGetCStringPtr(path, kCFStringEncodingMacRoman));
NSLogOut(@"[%3d%%] Copying %@ to device", percent / 2, path);
}
if (last_path != NULL) {
@@ -627,7 +651,7 @@ mach_error_t install_callback(CFDictionaryRef dict, int arg) {
CFStringRef status = CFDictionaryGetValue(dict, CFSTR("Status"));
CFNumberGetValue(CFDictionaryGetValue(dict, CFSTR("PercentComplete")), kCFNumberSInt32Type, &percent);
printf("[%3d%%] %s\n", (percent / 2) + 50, CFStringGetCStringPtr(status, kCFStringEncodingMacRoman));
NSLogOut(@"[%3d%%] %@", (percent / 2) + 50, status);
return 0;
}
@@ -662,8 +686,7 @@ CFURLRef copy_device_app_url(AMDeviceRef device, CFStringRef identifier) {
NSDictionary *optionsDict = [NSDictionary dictionaryWithObject:a forKey:@"ReturnAttributes"];
CFDictionaryRef options = (CFDictionaryRef)optionsDict;
afc_error_t resultStatus = AMDeviceLookupApplications(device, options, &result);
assert(resultStatus == 0);
check_error(AMDeviceLookupApplications(device, options, &result));
CFDictionaryRef app_dict = CFDictionaryGetValue(result, identifier);
assert(app_dict != NULL);
@@ -865,8 +888,7 @@ void fdvendor_callback(CFSocketRef s, CFSocketCallBackType callbackType, CFDataR
void start_remote_debug_server(AMDeviceRef device) {
int res = AMDeviceStartService(device, CFSTR("com.apple.debugserver"), &gdbfd, NULL);
assert(res == 0);
check_error(AMDeviceStartService(device, CFSTR("com.apple.debugserver"), &gdbfd, NULL));
assert(gdbfd > 0);
/*
@@ -895,7 +917,7 @@ void start_remote_debug_server(AMDeviceRef device) {
CFSocketSetAddress(fdvendor, address_data);
CFRelease(address_data);
socklen_t addrlen = sizeof(addr4);
res = getsockname(CFSocketGetNative(fdvendor),(struct sockaddr *)&addr4,&addrlen);
int res = getsockname(CFSocketGetNative(fdvendor),(struct sockaddr *)&addr4,&addrlen);
assert(res == 0);
port = ntohs(addr4.sin_port);
@@ -977,18 +999,18 @@ void setup_lldb(AMDeviceRef device, CFURLRef url) {
AMDeviceConnect(device);
assert(AMDeviceIsPaired(device));
assert(AMDeviceValidatePairing(device) == 0);
assert(AMDeviceStartSession(device) == 0);
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
@@ -996,8 +1018,8 @@ void setup_lldb(AMDeviceRef device, CFURLRef url) {
CFRelease(url);
printf("[100%%] Connecting to remote debug server\n");
printf("-------------------------\n");
NSLogOut(@"[100%%] Connecting to remote debug server");
NSLogOut(@"-------------------------");
setpgid(getpid(), 0);
signal(SIGHUP, killed);
@@ -1047,8 +1069,7 @@ void launch_debugger(AMDeviceRef device, CFURLRef url) {
} else if (pid > 0) {
child = pid;
} else {
perror("fork failed");
exit(exitcode_error);
on_sys_error(@"Fork failed");
}
}
@@ -1084,10 +1105,9 @@ void launch_debugger_and_exit(AMDeviceRef device, CFURLRef url) {
} else if (pid > 0) {
child = pid;
if (verbose)
printf("Waiting for child [Child: %d][Parent: %d]\n", child, parent);
NSLogOut(@"Waiting for child [Child: %d][Parent: %d]\n", child, parent);
} else {
perror("fork failed");
exit(exitcode_error);
on_sys_error(@"Fork failed");
}
}
@@ -1139,7 +1159,7 @@ void read_dir(service_conn_t afcFd, afc_connection* afc_conn_p, const char* dir,
AFCConnectionOpen(afcFd, 0, &afc_conn_p);
}
printf("%s\n", dir);
NSLogOut(@"%@", [NSString stringWithUTF8String:dir]);
afc_dictionary* afc_dict_p;
char *key, *val;
@@ -1200,25 +1220,23 @@ void read_dir(service_conn_t afcFd, afc_connection* afc_conn_p, const char* dir,
service_conn_t start_house_arrest_service(AMDeviceRef device) {
AMDeviceConnect(device);
assert(AMDeviceIsPaired(device));
assert(AMDeviceValidatePairing(device) == 0);
assert(AMDeviceStartSession(device) == 0);
check_error(AMDeviceValidatePairing(device));
check_error(AMDeviceStartSession(device));
service_conn_t houseFd;
if (bundle_id == NULL) {
printf("Bundle id is not specified\n");
exit(1);
on_error(@"Bundle id is not specified");
}
CFStringRef cf_bundle_id = CFStringCreateWithCString(NULL, bundle_id, kCFStringEncodingASCII);
if (AMDeviceStartHouseArrestService(device, cf_bundle_id, 0, &houseFd, 0) != 0)
{
printf("Unable to find bundle with id: %s\n", bundle_id);
exit(1);
on_error(@"Unable to find bundle with id: %@", bundle_id);
}
assert(AMDeviceStopSession(device) == 0);
assert(AMDeviceDisconnect(device) == 0);
check_error(AMDeviceStopSession(device));
check_error(AMDeviceDisconnect(device));
CFRelease(cf_bundle_id);
return houseFd;
@@ -1252,7 +1270,7 @@ void* read_file_to_memory(char * path, size_t* file_size)
*file_size = buf.st_size;
FILE* fd = fopen(path, "r");
char* content = malloc(*file_size);
if (fread(content, *file_size, 1, fd) != 1)
if (*file_size != 0 && fread(content, *file_size, 1, fd) != 1)
{
fclose(fd);
return NULL;
@@ -1275,35 +1293,57 @@ void list_files(AMDeviceRef device)
int app_exists(AMDeviceRef device)
{
if (bundle_id == NULL) {
printf("Bundle id is not specified\n");
return false;
NSLogOut(@"Bundle id is not specified.");
return 1;
}
AMDeviceConnect(device);
assert(AMDeviceIsPaired(device));
assert(AMDeviceValidatePairing(device) == 0);
assert(AMDeviceStartSession(device) == 0);
check_error(AMDeviceValidatePairing(device));
check_error(AMDeviceStartSession(device));
CFStringRef cf_bundle_id = CFStringCreateWithCString(NULL, bundle_id, kCFStringEncodingASCII);
NSArray *a = [NSArray arrayWithObjects:@"CFBundleIdentifier", nil];
NSDictionary *optionsDict = [NSDictionary dictionaryWithObject:a forKey:@"ReturnAttributes"];
CFDictionaryRef options = (CFDictionaryRef)optionsDict;
CFDictionaryRef result = nil;
afc_error_t resultStatus = AMDeviceLookupApplications(device, options, &result);
assert(resultStatus == 0);
CFDictionaryRef app_dict = CFDictionaryGetValue(result, cf_bundle_id);
int appExists = (app_dict == NULL) ? -1 : 0;
check_error(AMDeviceLookupApplications(device, options, &result));
bool appExists = CFDictionaryContainsKey(result, cf_bundle_id);
NSLogOut(@"%@", appExists ? @"true" : @"false");
CFRelease(cf_bundle_id);
assert(AMDeviceStopSession(device) == 0);
assert(AMDeviceDisconnect(device) == 0);
check_error(AMDeviceStopSession(device));
check_error(AMDeviceDisconnect(device));
if (appExists)
return 0;
return -1;
}
return appExists;
void list_bundle_id(AMDeviceRef device)
{
AMDeviceConnect(device);
assert(AMDeviceIsPaired(device));
check_error(AMDeviceValidatePairing(device));
check_error(AMDeviceStartSession(device));
NSArray *a = [NSArray arrayWithObjects:@"CFBundleIdentifier", nil];
NSDictionary *optionsDict = [NSDictionary dictionaryWithObject:a forKey:@"ReturnAttributes"];
CFDictionaryRef options = (CFDictionaryRef)optionsDict;
CFDictionaryRef result = nil;
check_error(AMDeviceLookupApplications(device, options, &result));
CFIndex count;
count = CFDictionaryGetCount(result);
const void *keys[count];
CFDictionaryGetKeysAndValues(result, keys, NULL);
for(int i = 0; i < count; ++i) {
CFStringRef test = (CFStringRef)keys[i];
NSLogOut(@"%@", (CFStringRef)keys[i]);
}
check_error(AMDeviceStopSession(device));
check_error(AMDeviceDisconnect(device));
}
void copy_file_callback(afc_connection* afc_conn_p, const char *name,int file)
@@ -1347,25 +1387,13 @@ void copy_file_callback(afc_connection* afc_conn_p, const char *name,int file)
}
}
void mkdirhier(char *path)
{
char *slash;
struct stat buf;
if (path[0]=='.' && path[1]=='/') path+=2;
if ((slash = strrchr(path,'/'))) {
*slash = '\0';
if (stat(path,&buf)==0) {
*slash = '/';
return;
}
mkdirhier(path);
mkdir (path,0777);
*slash = '/';
}
return;
BOOL mkdirp(NSString* path) {
NSError* error = nil;
BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:path
withIntermediateDirectories:YES
attributes:nil
error:&error];
return success;
}
void download_tree(AMDeviceRef device)
@@ -1373,12 +1401,15 @@ void download_tree(AMDeviceRef device)
service_conn_t houseFd = start_house_arrest_service(device);
afc_connection* afc_conn_p = NULL;
char *dirname = NULL;
NSString* targetPath = [NSString pathWithComponents:@[ @(target_filename), @(list_root)] ];
mkdirp([targetPath stringByDeletingLastPathComponent]);
if (AFCConnectionOpen(houseFd, 0, &afc_conn_p) == 0) do {
if (target_filename) {
dirname = strdup(target_filename);
mkdirhier(dirname);
mkdirp(@(dirname));
if (mkdir(dirname,0777) && errno!=EEXIST) {
fprintf(stderr,"mkdir(\"%s\") failed: %s\n",dirname,strerror(errno));
break;
@@ -1418,8 +1449,7 @@ void upload_file(AMDeviceRef device) {
if (!file_content)
{
printf("Could not open file: %s\n", upload_pathname);
exit(-1);
on_error(@"Could not open file: %@", upload_pathname);
}
// Make sure the directory was created
@@ -1433,18 +1463,16 @@ void upload_file(AMDeviceRef device) {
c++;
}
*lastSlash = '\0';
assert(AFCDirectoryCreate(afc_conn_p, dirpath) == 0);
check_error(AFCDirectoryCreate(afc_conn_p, dirpath));
}
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);
@@ -1484,7 +1512,7 @@ void remove_path(AMDeviceRef device) {
void uninstall_app(AMDeviceRef device) {
CFRetain(device); // don't know if this is necessary?
printf("------ Uninstall phase ------\n");
NSLogOut(@"------ Uninstall phase ------");
//Do we already have the bundle_id passed in via the command line? if so, use it.
CFStringRef cf_uninstall_bundle_id = NULL;
@@ -1492,26 +1520,25 @@ void uninstall_app(AMDeviceRef device) {
{
cf_uninstall_bundle_id = CFStringCreateWithCString(NULL, bundle_id, kCFStringEncodingASCII);
} else {
printf ("Error: you need to pass in the bundle id, (i.e. --bundle_id com.my.app)");
exit(1);
on_error(@"Error: you need to pass in the bundle id, (i.e. --bundle_id com.my.app)");
}
if (cf_uninstall_bundle_id == NULL) {
printf("Error: Unable to get bundle id from user command or package %s\n Uninstall failed\n", app_path);
on_error(@"Error: Unable to get bundle id from user command or package %@.\nUninstall failed.", app_path);
} else {
AMDeviceConnect(device);
assert(AMDeviceIsPaired(device));
assert(AMDeviceValidatePairing(device) == 0);
assert(AMDeviceStartSession(device) == 0);
check_error(AMDeviceValidatePairing(device));
check_error(AMDeviceStartSession(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);
}
assert(AMDeviceStopSession(device) == 0);
assert(AMDeviceDisconnect(device) == 0);
check_error(AMDeviceStopSession(device));
check_error(AMDeviceDisconnect(device));
}
}
@@ -1522,17 +1549,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, kCFStringEncodingASCII);
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 {
@@ -1540,7 +1569,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) {
@@ -1548,7 +1577,7 @@ void handle_device(AMDeviceRef device) {
} else if (strcmp("upload", command) == 0) {
upload_file(device);
} else if (strcmp("download", command) == 0) {
download_tree(device);
download_tree(device);
} else if (strcmp("mkdir", command) == 0) {
make_directory(device);
} else if (strcmp("rm", command) == 0) {
@@ -1557,6 +1586,8 @@ void handle_device(AMDeviceRef device) {
exit(app_exists(device));
} else if (strcmp("uninstall_only", command) == 0) {
uninstall_app(device);
} else if (strcmp("list_bundle_id", command) == 0) {
list_bundle_id(device);
}
exit(0);
}
@@ -1571,7 +1602,7 @@ void handle_device(AMDeviceRef device) {
CFRelease(relative_url);
if (uninstall) {
printf("------ Uninstall phase ------\n");
NSLogOut(@"------ Uninstall phase ------");
//Do we already have the bundle_id passed in via the command line? if so, use it.
CFStringRef cf_uninstall_bundle_id = NULL;
@@ -1583,46 +1614,46 @@ void handle_device(AMDeviceRef device) {
}
if (cf_uninstall_bundle_id == NULL) {
printf("Error: Unable to get bundle id from user command or package %s\n Uninstall failed\n", app_path);
on_error(@"Error: Unable to get bundle id from user command or package %@.\nUninstall failed.", app_path);
} else {
AMDeviceConnect(device);
assert(AMDeviceIsPaired(device));
assert(AMDeviceValidatePairing(device) == 0);
assert(AMDeviceStartSession(device) == 0);
check_error(AMDeviceValidatePairing(device));
check_error(AMDeviceStartSession(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);
}
assert(AMDeviceStopSession(device) == 0);
assert(AMDeviceDisconnect(device) == 0);
check_error(AMDeviceStopSession(device));
check_error(AMDeviceDisconnect(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));
assert(AMDeviceValidatePairing(device) == 0);
assert(AMDeviceStartSession(device) == 0);
check_error(AMDeviceValidatePairing(device));
check_error(AMDeviceStartSession(device));
// NOTE: the secure version doesn't seem to require us to start the AFC service
service_conn_t afcFd;
assert(AMDeviceSecureStartService(device, CFSTR("com.apple.afc"), NULL, &afcFd) == 0);
assert(AMDeviceStopSession(device) == 0);
assert(AMDeviceDisconnect(device) == 0);
check_error(AMDeviceSecureStartService(device, CFSTR("com.apple.afc"), NULL, &afcFd));
check_error(AMDeviceStopSession(device));
check_error(AMDeviceDisconnect(device));
CFStringRef keys[] = { CFSTR("PackageType") };
CFStringRef values[] = { CFSTR("Developer") };
CFDictionaryRef options = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
//assert(AMDeviceTransferApplication(afcFd, path, NULL, transfer_callback, NULL) == 0);
assert(AMDeviceSecureTransferPath(0, device, url, options, transfer_callback, 0)==0);
check_error(AMDeviceSecureTransferPath(0, device, url, options, transfer_callback, 0));
close(afcFd);
@@ -1630,8 +1661,8 @@ void handle_device(AMDeviceRef device) {
AMDeviceConnect(device);
assert(AMDeviceIsPaired(device));
assert(AMDeviceValidatePairing(device) == 0);
assert(AMDeviceStartSession(device) == 0);
check_error(AMDeviceValidatePairing(device));
check_error(AMDeviceStartSession(device));
// // NOTE: the secure version doesn't seem to require us to start the installation_proxy service
// // Although I can't find it right now, I in some code that the first param of AMDeviceSecureInstallApplication was a "dontStartInstallProxy"
@@ -1641,25 +1672,17 @@ void handle_device(AMDeviceRef device) {
//assert(AMDeviceSecureStartService(device, CFSTR("com.apple.mobile.installation_proxy"), NULL, &installFd) == 0);
//mach_error_t result = AMDeviceInstallApplication(installFd, path, options, install_callback, NULL);
mach_error_t result = AMDeviceSecureInstallApplication(0, device, url, options, install_callback, 0);
if (result != 0)
{
char* error = "Unknown error.";
if (result == 0xe8008015)
error = "Your application failed code-signing checks. Check your certificates, provisioning profiles, and bundle ids.";
printf("AMDeviceInstallApplication failed: 0x%X: %s\n", result, error);
exit(exitcode_error);
}
check_error(AMDeviceSecureInstallApplication(0, device, url, options, install_callback, 0));
// close(installFd);
assert(AMDeviceStopSession(device) == 0);
assert(AMDeviceDisconnect(device) == 0);
check_error(AMDeviceStopSession(device));
check_error(AMDeviceDisconnect(device));
CFRelease(path);
CFRelease(options);
printf("[100%%] Installed package %s\n", app_path);
NSLogOut(@"[100%%] Installed package %@", [NSString stringWithUTF8String:app_path]);
}
if (!debug)
@@ -1694,15 +1717,13 @@ void timeout_callback(CFRunLoopTimerRef timer, void *info) {
best_device_match = NULL;
}
if(!found_device) {
printf("[....] Timed out waiting for device.\n");
exit(exitcode_error);
}
if(!found_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) {
@@ -1714,7 +1735,7 @@ void timeout_callback(CFRunLoopTimerRef timer, void *info) {
{
if (verbose)
{
printf("Timeout. Killing child (%d) tree\n", child);
NSLogOut(@"Timeout. Killing child (%d) tree.", child);
}
kill_ptree(child, SIGHUP);
}
@@ -1724,37 +1745,38 @@ void timeout_callback(CFRunLoopTimerRef timer, void *info) {
}
void usage(const char* app) {
printf(
"Usage: %s [OPTION]...\n"
" -d, --debug launch the app in lldb after installation\n"
" -i, --id <device_id> the id of the device to connect to\n"
" -c, --detect only detect if the device is connected\n"
" -b, --bundle <bundle.app> the path to the app bundle to be installed\n"
" -a, --args <args> command line arguments to pass to the app when launching it\n"
" -t, --timeout <timeout> number of seconds to wait for a device to be connected\n"
" -u, --unbuffered don't buffer stdout\n"
" -n, --nostart do not start the app when debugging\n"
" -I, --noninteractive start in non interactive mode (quit when app crashes or exits)\n"
" -L, --justlaunch just launch the app and exit lldb\n"
" -v, --verbose enable verbose output\n"
" -m, --noinstall directly start debugging without app install (-d not required)\n"
" -p, --port <number> port used for device, default: dynamic\n"
" -r, --uninstall uninstall the app before install (do not use with -m; app cache and data are cleared) \n"
" -9, --uninstall_only uninstall the app ONLY. Use only with -1 <bundle_id> \n"
" -1, --bundle_id <bundle id> specify bundle id for list and upload\n"
" -l, --list list files\n"
" -o, --upload <file> upload file\n"
" -w, --download download app tree\n"
" -2, --to <target pathname> use together with up/download file/tree. specify target\n"
" -D, --mkdir <dir> make directory on device\n"
" -R, --rm <path> remove file or directory on device (directories must be empty)\n"
" -V, --version print the executable version \n"
" -e, --exists check if the app with given bundle_id is installed or not \n",
app);
NSLog(
@"Usage: %@ [OPTION]...\n"
@" -d, --debug launch the app in lldb after installation\n"
@" -i, --id <device_id> the id of the device to connect to\n"
@" -c, --detect only detect if the device is connected\n"
@" -b, --bundle <bundle.app> the path to the app bundle to be installed\n"
@" -a, --args <args> command line arguments to pass to the app when launching it\n"
@" -t, --timeout <timeout> number of seconds to wait for a device to be connected\n"
@" -u, --unbuffered don't buffer stdout\n"
@" -n, --nostart do not start the app when debugging\n"
@" -I, --noninteractive start in non interactive mode (quit when app crashes or exits)\n"
@" -L, --justlaunch just launch the app and exit lldb\n"
@" -v, --verbose enable verbose output\n"
@" -m, --noinstall directly start debugging without app install (-d not required)\n"
@" -p, --port <number> port used for device, default: dynamic\n"
@" -r, --uninstall uninstall the app before install (do not use with -m; app cache and data are cleared) \n"
@" -9, --uninstall_only uninstall the app ONLY. Use only with -1 <bundle_id> \n"
@" -1, --bundle_id <bundle id> specify bundle id for list and upload\n"
@" -l, --list list files\n"
@" -o, --upload <file> upload file\n"
@" -w, --download download app tree\n"
@" -2, --to <target pathname> use together with up/download file/tree. specify target\n"
@" -D, --mkdir <dir> make directory on device\n"
@" -R, --rm <path> remove file or directory on device (directories must be empty)\n"
@" -V, --version print the executable version \n"
@" -e, --exists check if the app with given bundle_id is installed or not \n"
@" -B, --list_bundle_id list bundle_id \n",
[NSString stringWithUTF8String:app]);
}
void show_version() {
printf("%s\n", APP_VERSION);
NSLogOut(@"%@", APP_VERSION);
}
int main(int argc, char *argv[]) {
@@ -1783,11 +1805,12 @@ int main(int argc, char *argv[]) {
{ "mkdir", required_argument, NULL, 'D'},
{ "rm", required_argument, NULL, 'R'},
{ "exists", no_argument, NULL, 'e'},
{ "list_bundle_id", no_argument, NULL, 'B'},
{ NULL, 0, NULL, 0 },
};
char ch;
while ((ch = getopt_long(argc, argv, "VmcdvunrILeD:R:i:b:a:t:g:x:p:1:2:o:l::w::9::", longopts, NULL)) != -1)
while ((ch = getopt_long(argc, argv, "VmcdvunrILeD:R:i:b:a:t:g:x:p:1:2:o:l::w::9::B::", longopts, NULL)) != -1)
{
switch (ch) {
case 'm':
@@ -1820,10 +1843,12 @@ int main(int argc, char *argv[]) {
break;
case 'I':
interactive = false;
debug = 1;
break;
case 'L':
interactive = false;
justlaunch = true;
debug = 1;
break;
case 'c':
detect_only = true;
@@ -1877,6 +1902,10 @@ int main(int argc, char *argv[]) {
command_only = true;
command = "exists";
break;
case 'B':
command_only = true;
command = "list_bundle_id";
break;
default:
usage(argv[0]);
return exitcode_error;
@@ -1885,8 +1914,7 @@ int main(int argc, char *argv[]) {
if (!app_path && !detect_only && !command_only) {
usage(argv[0]);
printf ("ERROR: One of -[b|c|o|l|w|D|R|e|9] is required to proceed!\n");
exit(exitcode_error);
on_error(@"One of -[b|c|o|l|w|D|R|e|9] is required to proceed!");
}
if (unbuffered) {
@@ -1895,11 +1923,13 @@ int main(int argc, char *argv[]) {
}
if (detect_only && timeout == 0) {
timeout = 0;
timeout = 5;
}
if (app_path) {
assert(access(app_path, F_OK) == 0);
if (access(app_path, F_OK) != 0) {
on_sys_error(@"Can't access app path '%@'", app_path);
}
}
AMDSetLogLevel(5); // otherwise syslog gets flooded with crap
@@ -1907,11 +1937,11 @@ int main(int argc, char *argv[]) {
{
CFRunLoopTimerRef timer = CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent() + timeout, 0, 0, 0, timeout_callback, NULL);
CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopCommonModes);
printf("[....] Waiting up to %d seconds for iOS device to be connected\n", timeout);
NSLogOut(@"[....] Waiting up to %d seconds for iOS device to be connected", timeout);
}
else
{
printf("[....] Waiting for iOS device to be connected\n");
NSLogOut(@"[....] Waiting for iOS device to be connected");
}
struct am_device_notification *notify;

View File

@@ -1,6 +1,6 @@
{
"name": "ios-deploy",
"version": "1.6.0",
"version": "1.7.0",
"os" : [ "darwin" ],
"description": "launch iOS apps iOS devices from the command line (Xcode 6)",
"main": "ios-deploy",