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/10/30 21:08:38 UTC
ios commit: CB-4805 (refis) Update cordova/run and
cordova/lib/install-device to use latest ios-deploy for iOS 7
Updated Branches:
refs/heads/master 9a63bb79d -> 5a194a96b
CB-4805 (refis) Update cordova/run and cordova/lib/install-device to use latest ios-deploy for iOS 7
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/5a194a96
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/5a194a96
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/5a194a96
Branch: refs/heads/master
Commit: 5a194a96bedf4470856eac6c1913c7c406ca64ae
Parents: 9a63bb7
Author: Shazron Abdullah <sh...@gmail.com>
Authored: Wed Oct 30 16:08:36 2013 -0400
Committer: Shazron Abdullah <sh...@gmail.com>
Committed: Wed Oct 30 16:08:36 2013 -0400
----------------------------------------------------------------------
bin/templates/scripts/cordova/run | 62 +++++++++++++++++++---------------
1 file changed, 35 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/5a194a96/bin/templates/scripts/cordova/run
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/run b/bin/templates/scripts/cordova/run
index 2d9740a..e497aac 100755
--- a/bin/templates/scripts/cordova/run
+++ b/bin/templates/scripts/cordova/run
@@ -27,6 +27,8 @@
OPTION_RESULT=()
TARGET="iPhone (Retina 3.5-inch)"
TARGET_FLAG='--family iphone --retina'
+# multi-device flow default
+USE_DEVICE=true
USE_SIMULATOR=false
# separates "key=value", sets an array with 0th index as key, 1st index as value
@@ -56,10 +58,11 @@ _parseArgs()
TARGET=${OPTION_RESULT[1]}
;;
"--device")
- echo "Targeting a device is not supported currently."
- exit 1
+ USE_DEVICE=true
+ USE_SIMULATOR=false
;;
"--emulator")
+ USE_DEVICE=false
USE_SIMULATOR=true
;;
esac
@@ -106,46 +109,51 @@ DEVICE_APP_PATH="$PROJECT_PATH/build/device/$PROJECT_NAME.app"
source "$CORDOVA_PATH/check_reqs"
-"$CORDOVA_PATH/build" || exit $?
# if device build found, run it first
-if [ -d "$DEVICE_APP_PATH" ] && ! "$USE_SIMULATOR"; then
+if "$USE_DEVICE"; then
IOS_DEPLOY_MIN_VERSION="1.0.4"
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;
+ 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" 1>&2;
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."
+ echo "Cordova needs ios-deploy version $IOS_DEPLOY_MIN_VERSION or greater, you have version $IOS_DEPLOY_VERSION." 1>&2;
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
+
+ DEVICE_CONNECTED=$(ios-deploy -c)
+ if [ $? != 0 ]; then
+ echo "No device is connected, trying Simulator." 1>&2;
+ USE_SIMULATOR=true
+ else
+ # if we got here, we can deploy the app, then exit success
+ "$CORDOVA_PATH/build" --device || exit $?
+ ios-deploy -d -b "$DEVICE_APP_PATH"
+ exit 0
+ fi
fi
-IOS_SIM_MIN_VERSION="1.7"
-IOS_SIM_LOCATION=$(which ios-sim)
-if [ $? != 0 ]; then
- echo -e "\033[31mError: ios-sim was not found. Please download, build and install version $IOS_SIM_MIN_VERSION or greater from https://github.com/phonegap/ios-sim into your path. Or 'npm install -g ios-sim' using node.js: http://nodejs.org/\033[m"; exit 1;
- exit 1
-fi
+if "$USE_SIMULATOR"; then
+ IOS_SIM_MIN_VERSION="1.7"
+ IOS_SIM_LOCATION=$(which ios-sim)
+ if [ $? != 0 ]; then
+ echo -e "\033[31mError: ios-sim was not found. Please download, build and install version $IOS_SIM_MIN_VERSION or greater from https://github.com/phonegap/ios-sim into your path. Or 'npm install -g ios-sim' using node.js: http://nodejs.org/\033[m" 1>&2;
+ exit 1
+ fi
-IOS_SIM_VERSION=$(ios-sim --version)
+ IOS_SIM_VERSION=$(ios-sim --version)
-if [[ "$IOS_SIM_VERSION" < "$IOS_SIM_MIN_VERSION" ]]; then
- echo "Cordova needs ios-sim version $IOS_SIM_MIN_VERSION or greater, you have version $IOS_SIM_VERSION."
- exit 1
+ if [[ "$IOS_SIM_VERSION" < "$IOS_SIM_MIN_VERSION" ]]; then
+ echo "Cordova needs ios-sim version $IOS_SIM_MIN_VERSION or greater, you have version $IOS_SIM_VERSION." 1>&2;
+ exit 1
+ fi
+
+ # launch using ios-sim
+ "$CORDOVA_PATH/build" --emulator || exit $?
+ ios-sim launch "$SIMULATOR_APP_PATH" --stderr "$CORDOVA_PATH/console.log" --stdout "$CORDOVA_PATH/console.log" $TARGET_FLAG --exit
fi
-# launch using ios-sim
-ios-sim launch "$SIMULATOR_APP_PATH" --stderr "$CORDOVA_PATH/console.log" --stdout "$CORDOVA_PATH/console.log" $TARGET_FLAG --exit