14 Commits
1.0.4 ... 1.0.6

Author SHA1 Message Date
Shazron Abdullah
f1a2c40566 Increment version to 1.0.6 2014-03-27 15:11:35 -07:00
Shazron Abdullah
c92682d148 Merge pull request #22 from Unity-Technologies/master
Add non interactive mode.
2014-03-27 12:35:25 -07:00
Julius Trinkunas
08f3b92306 Fix hangup when launching from scripts. 2014-03-27 16:14:14 +02:00
Julius Trinkunas
a4f3c2c84b Add non interactive mode. 2014-03-26 19:13:48 +02:00
Julius Trinkunas
a3a99e6553 Remove python wrapper shell. 2014-03-26 18:59:01 +02:00
wjywbs
7f2231bd39 Read port number in command line to debug app in multiple devices. 2014-03-24 14:37:03 -07:00
Shazron Abdullah
ad7c97d01f Updated version to 1.0.5 2014-03-20 17:03:52 -07:00
Shazron Abdullah
fa88a73a9a Fixes #20 - lldb startup super-slow unless ios-deploy.c is edited to match exact xcode version 2014-03-20 17:00:32 -07:00
Shazron Abdullah
83150622c2 Merge pull request #13 from zgramana/master
Fixes phonegap/ios-deploy#8.
2013-12-13 16:34:43 -08:00
Zachary Gramana
42f41798a6 Fixes phonegap/ios-deploy#8. 2013-12-13 16:02:14 -08:00
Shazron Abdullah
486d0d92e0 Merge pull request #12 from zgramana/master
Enabled LLDB interactive session. Perf improvement.
2013-12-12 13:39:43 -08:00
Zachary Gramana
c97735aaee Added back support for -n/--nostart option. 2013-12-10 11:18:13 -08:00
Zachary Gramana
d7c38e9e9f Enabled LLDB interactive session. Perf improvement. 2013-12-09 17:59:19 -08:00
Shazron Abdullah
6f78fbc5f3 Update README.md 2013-10-25 15:43:59 -07:00
4 changed files with 149 additions and 43 deletions

View File

@@ -1,4 +1,4 @@
IOS_CC = gcc
IOS_CC = gcc -ObjC
IOS_SDK = $(shell xcode-select --print-path)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk
DEVICE_SUPPORT = $(shell xcode-select --print-path)/Platforms/iPhoneOS.platform/DeviceSupport
@@ -11,10 +11,10 @@ demo.app: demo Info.plist
codesign -f -s "iPhone Developer" --entitlements Entitlements.plist demo.app
demo: demo.c
$(IOS_CC) -arch armv7 -isysroot $(IOS_SDK) -framework CoreFoundation -o 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) -o ios-deploy -framework CoreFoundation -framework MobileDevice -F/System/Library/PrivateFrameworks 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

View File

@@ -10,7 +10,7 @@ Install and debug iPhone apps without using Xcode. Designed to work on unjailbro
## Usage
./ios-deploy [OPTION]...
./ios-deploy [OPTION]...
-d, --debug launch the app in GDB after installation
-i, --id <device_id> the id of the device to connect to
-c, --detect only detect if the device is connected

View File

@@ -1,6 +1,7 @@
//TODO: don't copy/mount DeveloperDiskImage.dmg if it's already done - Xcode checks this somehow
#import <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
@@ -15,9 +16,9 @@
#include <netinet/tcp.h>
#include "MobileDevice.h"
#define APP_VERSION "1.0.4"
#define APP_VERSION "1.0.6"
#define PREP_CMDS_PATH "/tmp/fruitstrap-lldb-prep-cmds-"
#define LLDB_SHELL "python -u -c \"import time; time.sleep(0.5); print 'run'; time.sleep(2000000)\" | lldb -s " PREP_CMDS_PATH
#define LLDB_SHELL "lldb -s " PREP_CMDS_PATH
/*
* Startup script passed to lldb.
@@ -26,14 +27,29 @@
* log enable -v -f /Users/vargaz/gdb-remote.log gdb-remote all
*/
#define LLDB_PREP_CMDS CFSTR("\
platform select remote-ios --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/*\n\
platform select remote-ios --sysroot {symbols_path}\n\
target create \"{disk_app}\"\n\
script fruitstrap_device_app=\"{device_app}\"\n\
script fruitstrap_connect_url=\"connect://127.0.0.1:12345\"\n\
script fruitstrap_handle_command=\"command script add -s asynchronous -f {python_command}.fsrun_command run\"\n\
script fruitstrap_connect_url=\"connect://127.0.0.1:{device_port}\"\n\
command script import \"{python_file_path}\"\n\
command script add -f {python_command}.connect_command connect\n\
command script add -s asynchronous -f {python_command}.run_command run\n\
connect\n\
")
const char* lldb_prep_no_cmds = "";
const char* lldb_prep_interactive_cmds = "\
run\n\
";
const char* lldb_prep_noninteractive_cmds = "\
settings set -- auto-confirm true\n\
target stop-hook add --one-liner \"bt\"\n\
target stop-hook add --one-liner \"quit\"\n\
run\n\
";
/*
* Some things do not seem to work when using the normal commands like process connect/launch, so we invoke them
* through the python interface. Also, Launch () doesn't seem to work when ran from init_module (), so we add
@@ -42,19 +58,35 @@
#define LLDB_FRUITSTRAP_MODULE CFSTR("\
import lldb\n\
\n\
def __lldb_init_module(debugger, internal_dict):\n\
def connect_command(debugger, command, result, internal_dict):\n\
# These two are passed in by the script which loads us\n\
device_app=internal_dict['fruitstrap_device_app']\n\
connect_url=internal_dict['fruitstrap_connect_url']\n\
handle_command = internal_dict['fruitstrap_handle_command']\n\
lldb.target.modules[0].SetPlatformFileSpec(lldb.SBFileSpec(device_app))\n\
lldb.debugger.HandleCommand(handle_command)\n\
error=lldb.SBError()\n\
lldb.target.ConnectRemote(lldb.target.GetDebugger().GetListener(),connect_url,None,error)\n\
connect_url = internal_dict['fruitstrap_connect_url']\n\
error = lldb.SBError()\n\
\n\
def fsrun_command(debugger, command, result, internal_dict):\n\
error=lldb.SBError()\n\
lldb.target.Launch(lldb.SBLaunchInfo(['{args}']),error)\n\
process = lldb.target.ConnectRemote(lldb.target.GetDebugger().GetListener(), connect_url, None, error)\n\
\n\
# Wait for connection to succeed\n\
listener = lldb.target.GetDebugger().GetListener()\n\
listener.StartListeningForEvents(process.GetBroadcaster(), lldb.SBProcess.eBroadcastBitStateChanged)\n\
events = []\n\
state = lldb.eStateInvalid\n\
while state != lldb.eStateConnected:\n\
event = lldb.SBEvent()\n\
if listener.WaitForEvent(1, event):\n\
state = process.GetStateFromEvent(event)\n\
events.append(event)\n\
else:\n\
state = lldb.eStateInvalid\n\
\n\
# Add events back to queue, otherwise lldb freezes\n\
for event in events:\n\
listener.AddEvent(event)\n\
\n\
def run_command(debugger, command, result, internal_dict):\n\
device_app = internal_dict['fruitstrap_device_app']\n\
error = lldb.SBError()\n\
lldb.target.modules[0].SetPlatformFileSpec(lldb.SBFileSpec(device_app))\n\
lldb.target.Launch(lldb.SBLaunchInfo(['{args}']), error)\n\
print str(error)\n\
")
@@ -62,13 +94,15 @@ typedef struct am_device * AMDeviceRef;
int AMDeviceSecureTransferPath(int zero, AMDeviceRef device, CFURLRef url, CFDictionaryRef options, void *callback, int cbarg);
int AMDeviceSecureInstallApplication(int zero, AMDeviceRef device, CFURLRef url, CFDictionaryRef options, void *callback, int cbarg);
int AMDeviceMountImage(AMDeviceRef device, CFStringRef image, CFDictionaryRef options, void *callback, int cbarg);
int AMDeviceLookupApplications(AMDeviceRef device, int zero, CFDictionaryRef* result);
mach_error_t AMDeviceLookupApplications(AMDeviceRef device, CFDictionaryRef options, CFDictionaryRef *result);
bool found_device = false, debug = false, verbose = false, unbuffered = false, nostart = false, detect_only = false, install = true;
bool interactive = true;
char *app_path = NULL;
char *device_id = NULL;
char *args = NULL;
int timeout = 0;
int port = 12345;
CFStringRef last_path = NULL;
service_conn_t gdbfd;
pid_t parent = 0;
@@ -346,8 +380,38 @@ mach_error_t install_callback(CFDictionaryRef dict, int arg) {
}
CFURLRef copy_device_app_url(AMDeviceRef device, CFStringRef identifier) {
CFDictionaryRef result;
assert(AMDeviceLookupApplications(device, 0, &result) == 0);
CFDictionaryRef result = nil;
NSArray *a = [NSArray arrayWithObjects:
@"CFBundleIdentifier", // absolute must
@"ApplicationDSID",
@"ApplicationType",
@"CFBundleExecutable",
@"CFBundleDisplayName",
@"CFBundleIconFile",
@"CFBundleName",
@"CFBundleShortVersionString",
@"CFBundleSupportedPlatforms",
@"CFBundleURLTypes",
@"CodeInfoIdentifier",
@"Container",
@"Entitlements",
@"HasSettingsBundle",
@"IsUpgradeable",
@"MinimumOSVersion",
@"Path",
@"SignerIdentity",
@"UIDeviceFamily",
@"UIFileSharingEnabled",
@"UIStatusBarHidden",
@"UISupportedInterfaceOrientations",
nil];
NSDictionary *optionsDict = [NSDictionary dictionaryWithObject:a forKey:@"ReturnAttributes"];
CFDictionaryRef options = (CFDictionaryRef)optionsDict;
afc_error_t resultStatus = AMDeviceLookupApplications(device, options, &result);
assert(resultStatus == 0);
CFDictionaryRef app_dict = CFDictionaryGetValue(result, identifier);
assert(app_dict != NULL);
@@ -376,10 +440,15 @@ CFStringRef copy_disk_app_identifier(CFURLRef disk_app_url) {
}
void write_lldb_prep_cmds(AMDeviceRef device, CFURLRef disk_app_url) {
CFStringRef ds_path = copy_device_support_path(device);
CFStringRef symbols_path = CFStringCreateWithFormat(NULL, NULL, CFSTR("'%@/Symbols'"), ds_path);
CFMutableStringRef cmds = CFStringCreateMutableCopy(NULL, 0, LLDB_PREP_CMDS);
CFRange range = { 0, CFStringGetLength(cmds) };
CFStringRef ds_path = copy_device_support_path(device);
CFStringFindAndReplace(cmds, CFSTR("{symbols_path}"), symbols_path, range, 0);
range.length = CFStringGetLength(cmds);
CFStringFindAndReplace(cmds, CFSTR("{ds_path}"), ds_path, range, 0);
range.length = CFStringGetLength(cmds);
@@ -413,6 +482,10 @@ void write_lldb_prep_cmds(AMDeviceRef device, CFURLRef disk_app_url) {
CFStringFindAndReplace(cmds, CFSTR("{disk_app}"), disk_app_path, range, 0);
range.length = CFStringGetLength(cmds);
CFStringRef device_port = CFStringCreateWithFormat(NULL, NULL, CFSTR("%d"), port);
CFStringFindAndReplace(cmds, CFSTR("{device_port}"), device_port, range, 0);
range.length = CFStringGetLength(cmds);
CFURLRef device_container_url = CFURLCreateCopyDeletingLastPathComponent(NULL, device_app_url);
CFStringRef device_container_path = CFURLCopyFileSystemPath(device_container_url, kCFURLPOSIXPathStyle);
CFMutableStringRef dcp_noprivate = CFStringCreateMutableCopy(NULL, 0, device_container_path);
@@ -447,6 +520,15 @@ void write_lldb_prep_cmds(AMDeviceRef device, CFURLRef disk_app_url) {
strcat(prep_cmds_path, device_id);
FILE *out = fopen(prep_cmds_path, "w");
fwrite(CFDataGetBytePtr(cmds_data), CFDataGetLength(cmds_data), 1, out);
// Write additional commands based on mode we're running in
const char* extra_cmds;
if (!interactive)
extra_cmds = lldb_prep_noninteractive_cmds;
else if (nostart)
extra_cmds = lldb_prep_no_cmds;
else
extra_cmds = lldb_prep_interactive_cmds;
fwrite(extra_cmds, strlen(extra_cmds), 1, out);
fclose(out);
CFDataRef pmodule_data = CFStringCreateExternalRepresentation(NULL, pmodule, kCFStringEncodingASCII, 0);
@@ -535,7 +617,7 @@ void start_remote_debug_server(AMDeviceRef device) {
memset(&addr4, 0, sizeof(addr4));
addr4.sin_len = sizeof(addr4);
addr4.sin_family = AF_INET;
addr4.sin_port = htons(12345);
addr4.sin_port = htons(port);
addr4.sin_addr.s_addr = htonl(INADDR_ANY);
CFSocketRef fdvendor = CFSocketCreate(NULL, PF_INET, 0, 0, kCFSocketAcceptCallBack, &fdvendor_callback, NULL);
@@ -602,6 +684,16 @@ void lldb_finished_handler(int signum)
_exit(0);
}
void bring_process_to_foreground() {
if (setpgid(0, 0) == -1)
perror("setpgid failed");
signal(SIGTTOU, SIG_IGN);
if (tcsetpgrp(STDIN_FILENO, getpid()) == -1)
perror("tcsetpgrp failed");
signal(SIGTTOU, SIG_DFL);
}
void launch_debugger(AMDeviceRef device, CFURLRef url) {
AMDeviceConnect(device);
assert(AMDeviceIsPaired(device));
@@ -627,7 +719,11 @@ void launch_debugger(AMDeviceRef device, CFURLRef url) {
parent = getpid();
int pid = fork();
if (pid == 0) {
char lldb_shell[300] = LLDB_SHELL;
bring_process_to_foreground();
char lldb_shell[400];
sprintf(lldb_shell, LLDB_SHELL);
if(device_id != NULL)
strcat(lldb_shell, device_id);
system(lldb_shell); // launch lldb
@@ -746,8 +842,10 @@ void usage(const char* app) {
" -g, --gdbargs <args> extra arguments to pass to GDB when starting the debugger\n"
" -x, --gdbexec <file> GDB commands script file\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"
" -v, --verbose enable verbose output\n"
" -m, --noinstall directly start debugging without app install (-d not required) \n"
" -m, --noinstall directly start debugging without app install (-d not required)\n"
" -p, --port <number> port used for device, default: 12345 \n"
" -V, --version print the executable version \n",
app);
}
@@ -767,14 +865,16 @@ int main(int argc, char *argv[]) {
{ "gdbexec", no_argument, NULL, 'x' },
{ "unbuffered", no_argument, NULL, 'u' },
{ "nostart", no_argument, NULL, 'n' },
{ "noninteractive", no_argument, NULL, 'I' },
{ "detect", no_argument, NULL, 'c' },
{ "version", no_argument, NULL, 'V' },
{ "noinstall", no_argument, NULL, 'm' },
{ "port", required_argument, NULL, 'p' },
{ NULL, 0, NULL, 0 },
};
char ch;
while ((ch = getopt_long(argc, argv, "Vmcdvuni:b:a:t:g:x:", longopts, NULL)) != -1)
while ((ch = getopt_long(argc, argv, "VmcdvunIi:b:a:t:g:x:p:", longopts, NULL)) != -1)
{
switch (ch) {
case 'm':
@@ -805,12 +905,18 @@ int main(int argc, char *argv[]) {
case 'n':
nostart = 1;
break;
case 'I':
interactive = false;
break;
case 'c':
detect_only = true;
break;
case 'V':
show_version();
return 1;
case 'p':
port = atoi(optarg);
break;
default:
usage(argv[0]);
return 1;

View File

@@ -1,6 +1,6 @@
{
"name": "ios-deploy",
"version": "1.0.4",
"version": "1.0.6",
"description": "launch iOS apps iOS devices from the command line (Xcode 4)",
"main": "ios-deploy",
"scripts": {