我想使用包含的./emulator命令与Cordova/PhoneGap从命令行在iPad模拟器中运行我的应用程序。使用Cordova/PhoneGap模拟器命令模拟iPad
的基本说明在这里:
我已经安装了iOS模拟器从这里:
的文件说它支持从命令行模拟iPad。但是,它默认打开iPhone并将设备更改为“iPad”关闭应用程序(并且未安装在主屏幕上)。我搜索了但无法找到要启动的文档来模拟iPad。
如何运行Cordova ./emulator命令以打开iPad?
我想使用包含的./emulator命令与Cordova/PhoneGap从命令行在iPad模拟器中运行我的应用程序。使用Cordova/PhoneGap模拟器命令模拟iPad
的基本说明在这里:
我已经安装了iOS模拟器从这里:
的文件说它支持从命令行模拟iPad。但是,它默认打开iPhone并将设备更改为“iPad”关闭应用程序(并且未安装在主屏幕上)。我搜索了但无法找到要启动的文档来模拟iPad。
如何运行Cordova ./emulator命令以打开iPad?
Cordova emulate
脚本只是您可以直接从命令行使用的ios-sim
命令的包装。假设你的当前工作目录是一个与它的模拟脚本,可以在模拟器中的iPad模式下启动您的构建:
ios-sim launch ../build/myApp.app --family ipad --stderr console.log --stdout console.log &
下无疑是天真的(我不知道壳 - 脚本),但我已经破解了emulate
脚本以支持第二个命令行参数,该参数允许我指定设备系列。您可能不知道该脚本已经接受了第一个参数,该参数允许您指定项目文件的路径,因为如果未指定该参数,它将计算出路径。
更新你的脚本的版本具有以下(GitHub上叉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
然后就可以像这样运行脚本(假定您的当前工作目录是包含脚本的科尔多瓦目录):
./emulate ../build/myApp.app ipad
如果你总是要测试的iPad和你不喜欢有指定您的应用程序的路径每一次,你可能只是硬编码您的首选器件系列到脚本像这样和启动模拟器作为y OU此前已做:
ios-sim launch "$APP_PATH" --family ipad --stderr "$CORDOVA_PATH/console.log" --stdout "$CORDOVA_PATH/console.log" &
这可能是因为你使用的是旧版本的PhoneGap /科尔多瓦,但在3.4以下的工程版本对我来说:
cordova emulate ios --target="iPad"
对我来说,所有提到的这里的选项没有工作,我有这个命令来调用它显示了iPad的Retina:
``ios-sim launch [DIR_OF_APP]platforms/ios/build/emulator/My-App.app --devicetypeid "com.apple.CoreSimulator.SimDeviceType.iPad-Retina, 8.2"
检索所有devicetypeid's
型ios-sim showdevicetypes
http://docs.phonegap.com/en/2.2.0/guide_command-line_index.md。html#命令行%20Usage_ios – F481
谢谢,F481,但我链接到我的问题中的URL。它没有说如何将模拟器作为iPad(而不是iPhone)来启动。 –