You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2013/07/27 10:03:15 UTC

ios commit: [Cb-4336] modify cordova/run and cordova/install-device scripts to use ios-deploy (npm)

Updated Branches:
  refs/heads/master c87d1b0c6 -> 008a5015f


[Cb-4336] modify cordova/run and cordova/install-device scripts to use ios-deploy (npm)


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/008a5015
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/008a5015
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/008a5015

Branch: refs/heads/master
Commit: 008a5015febb5a4fc26c9d643f87184d82ba8e26
Parents: c87d1b0
Author: Shazron Abdullah <sh...@apache.org>
Authored: Sat Jul 27 01:03:06 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Sat Jul 27 01:03:06 2013 -0700

----------------------------------------------------------------------
 .../project/cordova/lib/install-device          | 40 ++++++++++++++++++--
 bin/templates/project/cordova/run               | 21 ++++++++++
 2 files changed, 58 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/008a5015/bin/templates/project/cordova/lib/install-device
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/install-device b/bin/templates/project/cordova/lib/install-device
index ad6993d..e16c283 100755
--- a/bin/templates/project/cordova/lib/install-device
+++ b/bin/templates/project/cordova/lib/install-device
@@ -24,7 +24,41 @@
 #     "iPad"
 #     "iPad (Retina)"
 
-set -e
+XCODE_VER=$(xcodebuild -version | head -n 1 | sed -e 's/Xcode //')
+XCODE_MIN_VERSION="4.6"
 
-echo 'iOS: Not able to install to device through command-line at this time.'
-exit 1
\ No newline at end of file
+if [[ "$XCODE_VER" < "$XCODE_MIN_VERSION" ]]; then
+	echo "Cordova can only run in Xcode version $XCODE_MIN_VERSION or greater."
+	exit 1
+fi
+
+LIB_PATH=$( cd "$( dirname "$0" )" && pwd -P)
+CORDOVA_PATH="$(dirname "$LIB_PATH")"
+PROJECT_PATH="$(dirname "$CORDOVA_PATH")"
+XCODEPROJ=$( ls "$PROJECT_PATH" | grep .xcodeproj  )
+PROJECT_NAME=$(basename "$XCODEPROJ" .xcodeproj)
+
+DEVICE_APP_PATH="$PROJECT_PATH/build/device/$PROJECT_NAME.app"
+
+if [ ! -d "$DEVICE_APP_PATH" ]; then
+	echo "Project '$DEVIC_APP_PATH' is not built."
+    exit 1
+fi
+
+
+IOS_DEPLOY_MIN_VERSION="1.0.2"
+IOS_DEPLOY_LOCATION=$(which ios-deploy)
+if [ $? != 0 ]; then
+    echo -e "\033[31mError: ios-deploy was not found. Please download, build and install version $IOS_DEPLOY_MIN_VERSION or greater from https://github.com/phonegap/ios-deploy into your path. Or 'npm install -g ios-deploy' using node.js: http://nodejs.org/\033[m"; exit 1;
+	exit 1
+fi
+
+IOS_DEPLOY_VERSION=$(ios-deploy --version)
+if [[ "$IOS_DEPLOY_VERSION" < "$IOS_DEPLOY_MIN_VERSION" ]]; then
+	echo "Cordova needs ios-deploy version $IOS_DEPLOY_MIN_VERSION or greater, you have version $IOS_DEPLOY_VERSION."
+	exit 1
+fi
+
+# if we got here, we can deploy the app, then exit success
+ios-deploy -b "$DEVICE_APP_PATH"
+exit 0

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/008a5015/bin/templates/project/cordova/run
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/run b/bin/templates/project/cordova/run
index ba6b6bb..a96666e 100755
--- a/bin/templates/project/cordova/run
+++ b/bin/templates/project/cordova/run
@@ -106,9 +106,30 @@ XCODEPROJ=$( ls "$PROJECT_PATH" | grep .xcodeproj  )
 PROJECT_NAME=$(basename "$XCODEPROJ" .xcodeproj)
 
 SIMULATOR_APP_PATH="$PROJECT_PATH/build/emulator/$PROJECT_NAME.app"
+DEVICE_APP_PATH="$PROJECT_PATH/build/device/$PROJECT_NAME.app"
 
 "$CORDOVA_PATH/build" || exit $?
 
+# if device build found, run it first
+if [ -d "$DEVICE_APP_PATH" ]; then
+    IOS_DEPLOY_MIN_VERSION="1.0.2"
+    IOS_DEPLOY_LOCATION=$(which ios-deploy)
+    if [ $? != 0 ]; then
+        echo -e "\033[31mError: ios-deploy was not found. Please download, build and install version $IOS_DEPLOY_MIN_VERSION or greater from https://github.com/phonegap/ios-deploy into your path. Or 'npm install -g ios-deploy' using node.js: http://nodejs.org/\033[m"; exit 1;
+    	exit 1
+    fi
+
+    IOS_DEPLOY_VERSION=$(ios-deploy --version)
+    if [[ "$IOS_DEPLOY_VERSION" < "$IOS_DEPLOY_MIN_VERSION" ]]; then
+    	echo "Cordova needs ios-deploy version $IOS_DEPLOY_MIN_VERSION or greater, you have version $IOS_DEPLOY_VERSION."
+    	exit 1
+    fi
+    
+    # if we got here, we can deploy the app, then exit success
+    ios-deploy -d -b "$DEVICE_APP_PATH"
+	exit 0
+fi
+
 if [ ! -d "$SIMULATOR_APP_PATH" ]; then
 	echo "$SIMULATOR_APP_PATH not found to emulate."
 	exit 1