The emulate script is just a shell for the ios-sim command, which you can use directly from the command line. Assuming your current working directory is such that it has an emulation script in it, you can run your build in an emulator in iPad mode with the following:
ios-sim launch ../build/myApp.app --family ipad --stderr console.log --stdout console.log &
Sure, the following is naive (I don't know shell-scripting), but I hacked an emulate script to support a second command line parameter that allows me to specify a device family. You may not know that the script is already accepting the first parameter, which allows you to specify the path to your .app project, since it determines the path if the parameter is not specified.
Update your version of the script as follows (here, here, here:
>)
#! /bin/sh # # Licensing info removed for brevity # set -e XCODE_VER=$(xcodebuild -version | head -n 1 | sed -e 's/Xcode //') XCODE_MIN_VERSION="4.5" if [[ "$XCODE_VER" < "$XCODE_MIN_VERSION" ]]; then echo "Cordova can only run in Xcode version $XCODE_MIN_VERSION or greater." exit 1 fi CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd -P) PROJECT_PATH="$(dirname "$CORDOVA_PATH")" XCODEPROJ=$( ls "$PROJECT_PATH" | grep .xcodeproj ) PROJECT_NAME=$(basename "$XCODEPROJ" .xcodeproj) APP_PATH=$1 DEVICE_FAMILY=$2 if [ $# -lt 1 ]; then APP_PATH="$PROJECT_PATH/build/$PROJECT_NAME.app" DEVICE_FAMILY=iphone fi if [ ! -d "$APP_PATH" ]; then echo "Project '$APP_PATH' is not built. Building." $CORDOVA_PATH/build || exit $? fi if [ ! -d "$APP_PATH" ]; then echo "$APP_PATH not found to emulate." exit 1 fi # launch using ios-sim if which ios-sim >/dev/null; then ios-sim launch "$APP_PATH" --family "$DEVICE_FAMILY" --stderr "$CORDOVA_PATH/console.log" --stdout "$CORDOVA_PATH/console.log" & else echo -e '\033[31mError: ios-sim was not found. Please download, build and install version 1.4 or greater from https://github.com/phonegap/ios-sim into your path. Or "brew install ios-sim" using homebrew: http://mxcl.github.com/homebrew/\033[m'; exit 1; fi
Then you can run the script as follows (assuming your current working directory is a cord directory containing scripts):
./emulate ../build/myApp.app ipad
If you will always test the iPad, and you do not want to indicate the path to your application every time, you can simply copy your preferred device family into a script on how to do this, and run the emulator as you did before:
ios-sim launch "$APP_PATH" --family ipad --stderr "$CORDOVA_PATH/console.log" --stdout "$CORDOVA_PATH/console.log" &
net.uk.sweet Feb 07 '13 at 23:12 2013-02-07 23:12
source share