From 7bffd7232891ca2d327ced20a4a725fdd6a2dfa1 Mon Sep 17 00:00:00 2001 From: "aharbick@aharbick.com" Date: Thu, 25 Sep 2014 15:09:22 -0400 Subject: [PATCH 1/2] Pass devicetypeid instead of --target to match changes to ios-sim --- bin/templates/scripts/cordova/emulate | 4 +- .../scripts/cordova/lib/install-emulator | 54 +++++------------- bin/templates/scripts/cordova/run | 56 ++++++------------- 3 files changed, 34 insertions(+), 80 deletions(-) diff --git a/bin/templates/scripts/cordova/emulate b/bin/templates/scripts/cordova/emulate index 241cbb65ff..0b4cab078a 100755 --- a/bin/templates/scripts/cordova/emulate +++ b/bin/templates/scripts/cordova/emulate @@ -29,7 +29,7 @@ source "$CORDOVA_PATH/check_reqs" APP_PATH=${1:-$PROJECT_PATH/build/emulator/$(xcodebuild -project "$PROJECT_PATH/$PROJECT_NAME.xcodeproj" -arch i386 -target "$PROJECT_NAME" -configuration Debug -sdk $SDK -showBuildSettings | grep FULL_PRODUCT_NAME | awk -F ' = ' '{print $2}')} -DEVICE_FAMILY=${2:-${DEVICE_FAMILY:-iphone}} +DEVICE_TYPE=${2:-${DEVICE_TYPE:-com.apple.CoreSimulator.SimDeviceType.iPhone-6}} IOS_SIM_MIN_VERSION="1.7" IOS_SIM_LOCATION=$(which ios-sim) @@ -56,4 +56,4 @@ if [ ! -d "$APP_PATH" ]; then fi # launch using ios-sim -ios-sim launch "$APP_PATH" --family "$DEVICE_FAMILY" --stderr "$CORDOVA_PATH/console.log" --stdout "$CORDOVA_PATH/console.log" --exit +ios-sim launch "$APP_PATH" --devicetypeid "$DEVICE_TYPE" --stderr "$CORDOVA_PATH/console.log" --stdout "$CORDOVA_PATH/console.log" --exit diff --git a/bin/templates/scripts/cordova/lib/install-emulator b/bin/templates/scripts/cordova/lib/install-emulator index ae2c47af6e..7a05a8b904 100755 --- a/bin/templates/scripts/cordova/lib/install-emulator +++ b/bin/templates/scripts/cordova/lib/install-emulator @@ -17,16 +17,20 @@ # specific language governing permissions and limitations # under the License. # -# Valid values for "--target" (case insensitive): -# "iPhone (Retina 3.5-inch)" (default) -# "iPhone (Retina 4-inch)" -# "iPhone" -# "iPad" -# "iPad (Retina)" +# Valid values for "--devicetypeid" (case sensitive): +# com.apple.CoreSimulator.SimDeviceType.iPhone-4s +# com.apple.CoreSimulator.SimDeviceType.iPhone-5 +# com.apple.CoreSimulator.SimDeviceType.iPhone-5s +# com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus +# com.apple.CoreSimulator.SimDeviceType.iPhone-6 +# com.apple.CoreSimulator.SimDeviceType.iPad-2 +# com.apple.CoreSimulator.SimDeviceType.iPad-Retina +# com.apple.CoreSimulator.SimDeviceType.iPad-Air +# com.apple.CoreSimulator.SimDeviceType.Resizable-iPhone +# com.apple.CoreSimulator.SimDeviceType.Resizable-iPad OPTION_RESULT=() -TARGET="iPhone (Retina 3.5-inch)" -TARGET_FLAG='--family iphone --retina' +DEVICE_TYPE="com.apple.CoreSimulator.SimDeviceType.iPhone-6" # separates "key=value", sets an array with 0th index as key, 1st index as value _parseOption() @@ -51,8 +55,8 @@ _parseArgs() do _parseOption ${arg} case "${OPTION_RESULT[0]}" in - "--target") - TARGET=${OPTION_RESULT[1]} + "--devicetypeid") + DEVICE_TYPE=${OPTION_RESULT[1]} ;; esac done @@ -60,32 +64,6 @@ _parseArgs() _parseArgs "$@" -# lowercase the target string -TARGET_LC=`echo $TARGET | tr '[:upper:]' '[:lower:]'` - -# remember the comparison is lowercase -case "$TARGET_LC" in - "iphone (retina 3.5-inch)") - TARGET_FLAG="--family iphone --retina" - ;; - "iphone (retina 4-inch)") - TARGET_FLAG="--family iphone --retina --tall" - ;; - # --64bit not supportted by ios-sim yet - #"iphone retina (4-inch 64-bit)") - #TARGET_FLAG="--family iphone --retina --tall --64bit" - #;; - "iphone") - TARGET_FLAG="--family iphone" - ;; - "ipad") - TARGET_FLAG="--family ipad" - ;; - "ipad (retina)") - TARGET_FLAG="--family ipad --retina" - ;; -esac - LIB_PATH=$( cd "$( dirname "$0" )" && pwd -P) CORDOVA_PATH="$(dirname "$LIB_PATH")" PROJECT_PATH="$(dirname "$CORDOVA_PATH")" @@ -121,6 +99,4 @@ if [[ "$IOS_SIM_VERSION" < "$IOS_SIM_MIN_VERSION" ]]; then fi # launch using ios-sim -ios-sim launch "$SIMULATOR_APP_PATH" --stderr "$CORDOVA_PATH/console.log" --stdout "$CORDOVA_PATH/console.log" $TARGET_FLAG --exit - - +ios-sim launch "$SIMULATOR_APP_PATH" --stderr "$CORDOVA_PATH/console.log" --stdout "$CORDOVA_PATH/console.log" --devicetypeid $DEVICE_TYPE --exit diff --git a/bin/templates/scripts/cordova/run b/bin/templates/scripts/cordova/run index e497aac35d..bc5812d0a2 100755 --- a/bin/templates/scripts/cordova/run +++ b/bin/templates/scripts/cordova/run @@ -17,16 +17,22 @@ # specific language governing permissions and limitations # under the License. # -# Valid values for "--target" (case insensitive): -# "iPhone (Retina 3.5-inch)" (default) -# "iPhone (Retina 4-inch)" -# "iPhone" -# "iPad" -# "iPad (Retina)" +# Valid values for "--devicetypeid" (case sensitive): +# com.apple.CoreSimulator.SimDeviceType.iPhone-4s +# com.apple.CoreSimulator.SimDeviceType.iPhone-5 +# com.apple.CoreSimulator.SimDeviceType.iPhone-5s +# com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus +# com.apple.CoreSimulator.SimDeviceType.iPhone-6 +# com.apple.CoreSimulator.SimDeviceType.iPad-2 +# com.apple.CoreSimulator.SimDeviceType.iPad-Retina +# com.apple.CoreSimulator.SimDeviceType.iPad-Air +# com.apple.CoreSimulator.SimDeviceType.Resizable-iPhone +# com.apple.CoreSimulator.SimDeviceType.Resizable-iPad + OPTION_RESULT=() -TARGET="iPhone (Retina 3.5-inch)" -TARGET_FLAG='--family iphone --retina' +DEVICE_TYPE="com.apple.CoreSimulator.SimDeviceType.iPhone-6" + # multi-device flow default USE_DEVICE=true USE_SIMULATOR=false @@ -54,8 +60,8 @@ _parseArgs() do _parseOption ${arg} case "${OPTION_RESULT[0]}" in - "--target") - TARGET=${OPTION_RESULT[1]} + "--devicetypeid") + DEVICE_TYPE=${OPTION_RESULT[1]} ;; "--device") USE_DEVICE=true @@ -71,34 +77,6 @@ _parseArgs() _parseArgs "$@" -# "iPhone (Retina 3.5-inch)" -> --family iphone --retina -# "iPhone (Retina 4-inch)" -> --family iphone --retina --tall -# "iPhone" -> --family iphone -# "iPad" -> --family ipad -# "iPad (Retina)" -> --family ipad --retina - -# lowercase the target string -TARGET_LC=`echo $TARGET | tr '[:upper:]' '[:lower:]'` - -# remember the comparison is lowercase -case "$TARGET_LC" in - "iphone (retina 3.5-inch)") - TARGET_FLAG="--family iphone --retina" - ;; - "iphone (retina 4-inch)") - TARGET_FLAG="--family iphone --retina --tall" - ;; - "iphone") - TARGET_FLAG="--family iphone" - ;; - "ipad") - TARGET_FLAG="--family ipad" - ;; - "ipad (retina)") - TARGET_FLAG="--family ipad --retina" - ;; -esac - CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd -P) PROJECT_PATH="$(dirname "$CORDOVA_PATH")" XCODEPROJ=$( ls "$PROJECT_PATH" | grep .xcodeproj ) @@ -154,6 +132,6 @@ if "$USE_SIMULATOR"; then # 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 + ios-sim launch "$SIMULATOR_APP_PATH" --stderr "$CORDOVA_PATH/console.log" --stdout "$CORDOVA_PATH/console.log" --devicetypeid $DEVICE_TYPE --exit fi From e8eb1a822266596b67b3d32b798898ff4a70af87 Mon Sep 17 00:00:00 2001 From: "aharbick@aharbick.com" Date: Thu, 25 Sep 2014 21:46:00 -0400 Subject: [PATCH 2/2] Responding to feedback from @purplecabbage. Keep the argument as --target and don't require the full deviceid (e.g. iPhone-6 is enough) --- bin/templates/scripts/cordova/emulate | 4 +-- .../scripts/cordova/lib/install-emulator | 30 +++++++++---------- bin/templates/scripts/cordova/run | 30 +++++++++---------- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/bin/templates/scripts/cordova/emulate b/bin/templates/scripts/cordova/emulate index 0b4cab078a..638e650c12 100755 --- a/bin/templates/scripts/cordova/emulate +++ b/bin/templates/scripts/cordova/emulate @@ -29,7 +29,7 @@ source "$CORDOVA_PATH/check_reqs" APP_PATH=${1:-$PROJECT_PATH/build/emulator/$(xcodebuild -project "$PROJECT_PATH/$PROJECT_NAME.xcodeproj" -arch i386 -target "$PROJECT_NAME" -configuration Debug -sdk $SDK -showBuildSettings | grep FULL_PRODUCT_NAME | awk -F ' = ' '{print $2}')} -DEVICE_TYPE=${2:-${DEVICE_TYPE:-com.apple.CoreSimulator.SimDeviceType.iPhone-6}} +TARGET=${2:-${TARGET:-iPhone-6}} IOS_SIM_MIN_VERSION="1.7" IOS_SIM_LOCATION=$(which ios-sim) @@ -56,4 +56,4 @@ if [ ! -d "$APP_PATH" ]; then fi # launch using ios-sim -ios-sim launch "$APP_PATH" --devicetypeid "$DEVICE_TYPE" --stderr "$CORDOVA_PATH/console.log" --stdout "$CORDOVA_PATH/console.log" --exit +ios-sim launch "$APP_PATH" --devicetypeid "com.apple.CoreSimulator.SimDeviceType.$TARGET" --stderr "$CORDOVA_PATH/console.log" --stdout "$CORDOVA_PATH/console.log" --exit diff --git a/bin/templates/scripts/cordova/lib/install-emulator b/bin/templates/scripts/cordova/lib/install-emulator index 7a05a8b904..e916660a6d 100755 --- a/bin/templates/scripts/cordova/lib/install-emulator +++ b/bin/templates/scripts/cordova/lib/install-emulator @@ -17,20 +17,20 @@ # specific language governing permissions and limitations # under the License. # -# Valid values for "--devicetypeid" (case sensitive): -# com.apple.CoreSimulator.SimDeviceType.iPhone-4s -# com.apple.CoreSimulator.SimDeviceType.iPhone-5 -# com.apple.CoreSimulator.SimDeviceType.iPhone-5s -# com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus -# com.apple.CoreSimulator.SimDeviceType.iPhone-6 -# com.apple.CoreSimulator.SimDeviceType.iPad-2 -# com.apple.CoreSimulator.SimDeviceType.iPad-Retina -# com.apple.CoreSimulator.SimDeviceType.iPad-Air -# com.apple.CoreSimulator.SimDeviceType.Resizable-iPhone -# com.apple.CoreSimulator.SimDeviceType.Resizable-iPad +# Valid values for "--target" (case sensitive): +# iPhone-4s +# iPhone-5 +# iPhone-5s +# iPhone-6-Plus +# iPhone-6 +# iPad-2 +# iPad-Retina +# iPad-Air +# Resizable-iPhone +# Resizable-iPad OPTION_RESULT=() -DEVICE_TYPE="com.apple.CoreSimulator.SimDeviceType.iPhone-6" +TARGET="iPhone-6" # separates "key=value", sets an array with 0th index as key, 1st index as value _parseOption() @@ -55,8 +55,8 @@ _parseArgs() do _parseOption ${arg} case "${OPTION_RESULT[0]}" in - "--devicetypeid") - DEVICE_TYPE=${OPTION_RESULT[1]} + "--target") + TARGET=${OPTION_RESULT[1]} ;; esac done @@ -99,4 +99,4 @@ if [[ "$IOS_SIM_VERSION" < "$IOS_SIM_MIN_VERSION" ]]; then fi # launch using ios-sim -ios-sim launch "$SIMULATOR_APP_PATH" --stderr "$CORDOVA_PATH/console.log" --stdout "$CORDOVA_PATH/console.log" --devicetypeid $DEVICE_TYPE --exit +ios-sim launch "$SIMULATOR_APP_PATH" --stderr "$CORDOVA_PATH/console.log" --stdout "$CORDOVA_PATH/console.log" --devicetypeid $TARGET --exit diff --git a/bin/templates/scripts/cordova/run b/bin/templates/scripts/cordova/run index bc5812d0a2..b4d45d00d3 100755 --- a/bin/templates/scripts/cordova/run +++ b/bin/templates/scripts/cordova/run @@ -17,21 +17,21 @@ # specific language governing permissions and limitations # under the License. # -# Valid values for "--devicetypeid" (case sensitive): -# com.apple.CoreSimulator.SimDeviceType.iPhone-4s -# com.apple.CoreSimulator.SimDeviceType.iPhone-5 -# com.apple.CoreSimulator.SimDeviceType.iPhone-5s -# com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus -# com.apple.CoreSimulator.SimDeviceType.iPhone-6 -# com.apple.CoreSimulator.SimDeviceType.iPad-2 -# com.apple.CoreSimulator.SimDeviceType.iPad-Retina -# com.apple.CoreSimulator.SimDeviceType.iPad-Air -# com.apple.CoreSimulator.SimDeviceType.Resizable-iPhone -# com.apple.CoreSimulator.SimDeviceType.Resizable-iPad +# Valid values for "--target" (case sensitive): +# iPhone-4s +# iPhone-5 +# iPhone-5s +# iPhone-6-Plus +# iPhone-6 +# iPad-2 +# iPad-Retina +# iPad-Air +# Resizable-iPhone +# Resizable-iPad OPTION_RESULT=() -DEVICE_TYPE="com.apple.CoreSimulator.SimDeviceType.iPhone-6" +TARGET="iPhone-6" # multi-device flow default USE_DEVICE=true @@ -60,8 +60,8 @@ _parseArgs() do _parseOption ${arg} case "${OPTION_RESULT[0]}" in - "--devicetypeid") - DEVICE_TYPE=${OPTION_RESULT[1]} + "--target") + TARGET=${OPTION_RESULT[1]} ;; "--device") USE_DEVICE=true @@ -132,6 +132,6 @@ if "$USE_SIMULATOR"; then # 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" --devicetypeid $DEVICE_TYPE --exit + ios-sim launch "$SIMULATOR_APP_PATH" --stderr "$CORDOVA_PATH/console.log" --stdout "$CORDOVA_PATH/console.log" --devicetypeid com.apple.CoreSimulator.SimDeviceType.$TARGET --exit fi