Simulate an iPad using the Cordova / PhoneGap emulator command

I would like to use the attached command. / emulator with Cordova / PhoneGap to launch my application in the iPad simulator from the command line.

Basic instructions are given here:

I installed the iOS simulator here:

The documentation says that it supports simulating an iPad from the command line. However, by default, it opens the iPhone, and changing the device to "iPad" closes the application (and it is not installed on the main screen). I searched, but cannot find documentation to run to simulate an iPad.

How to run the Cordova./emulator command to open an iPad?

+9
ios ios-simulator ipad cordova
Dec 14 '12 at 11:29
source share
3 answers

You may have used the old version of phonegap / cordova, but in version 3.4 the following works for me:

cordova emulate ios --target="iPad" 
+18
May 05 '14 at
source share

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" & 
+8
Feb 07 '13 at 23:12
source share

For me, all of the options listed here did not work here, I had to call it with this command in order to show iPad Retina:

 ``ios-sim launch [DIR_OF_APP]platforms/ios/build/emulator/My-App.app --devicetypeid "com.apple.CoreSimulator.SimDeviceType.iPad-Retina, 8.2" 

To get all type devicetypeid's ios-sim showdevicetypes

0
Apr 6 '15 at 15:12
source share



All Articles