Cordova:启动特定iOS模拟器图像 [英] Cordova: start specific iOS emulator image

查看:544
本文介绍了Cordova:启动特定iOS模拟器图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Cordova开发一个跨平台的移动应用程序,主要关注iOS在开发阶段。



对于我的开发过程,如果我可以直接从命令行启动我的Cordova应用程序并将其加载到指定的模拟器中,这将是理想的。我可以通过从项目根目录运行以下命令来实现:

  $ cordova run --debug --emulator iOS 

这样运行正常,导致一个iOS模拟器运行我的应用程序在模拟iPhone 4 Retina与iOS 7.0 .3



除了这个模拟的设备,我还想测试(例如)一个iPad。我安装了这些模拟图像,我可以在Xcode中手动启动我的应用程序。此外,命令 list-emulator-images (位于 project_dir / platforms / ios / cordova / lib 以下输出:

 iPhone Retina(3.5英寸)
iPhone Retina b $ biPhone Retina(4英寸64位)
iPhone
iPad
iPad Retina
pre>

然而,事情是:我似乎不知道如何启动模拟器的任何东西,除了默认(它似乎是 iPhone Retina(4英寸)模拟图像)。 cordova help 的相关输出提供以下信息:

  --debug | --release] 
[--device | --emulator | --target = FOO]
[PLATFORM] ................ ............在指定平台设备/模拟器上部署应用程序

I已尝试以下操作:



cordova run --debug --emulator = iPad iOS



及其许多变体,但没有运气。每次它在同一个模拟器中启动。



命令行工具的文档在这方面不提供任何信息,广泛的Google搜索也无法打开任何东西。我缺少一些小事?还是我想做一些奇怪的事?我真的希望有人在这里有这方面的经验,并可以提供一些答案。



非常感谢!



编辑:忘记提及;我在Mac上做这一切。如前所述,在Xcode中在不同的模拟器/模拟器中运行应用程序很好。

解决方案

您可以使用列出它们

  $ cordova emulate ios --list 
可用的iOS虚拟设备:
iPhone-4s,9.3
iPhone-5,9.3
iPhone-5s,9.3
iPhone-6,9.3
iPhone-6-Plus,9.3
iPhone- 6s,9.3
iPhone-6s-Plus,9.3
iPad-2,9.3
iPad-Retina,9.3
iPad-Air,9.3
iPad-Air-2 ,9.3
iPad-Pro,9.3

然后使用其中一个模拟器名称 - -target参数:

  cordova emulate ios --target =iPhone-4s,9.3
cordova emulate ios - -target =iPad-Air-2,9.3
cordova emulate ios --target =iPhone-6s,9.3
cordova emulate ios --target =iPhone-6-Plus,9.3

重要在启动不同的目标模拟器之前退出模拟器选择 Simulator->退出



考虑到您可能需要通过菜单退出iOS模拟器从3.5到4英寸iPhone。



动态列表可在 platforms / ios / cordova / lib / list-emulator-images


I'm developing a cross-platform mobile app using Cordova, focussing mainly on iOS in the development stage.

For my development process it would be ideal if I could start my Cordova app directly from the command line and have it load into a specified emulator. I can do this by running the following from the project root directory:

$cordova run --debug --emulator iOS

This works fine, and results in an iOS-simulator running my app in a simulated iPhone 4 Retina with iOS 7.0.3

Besides this simulated device, I would also like to test on (for instance) an iPad. I have these emulation images installed, and I can start my app in them manually in Xcode. Also, the command list-emulator-images (located in project_dir/platforms/ios/cordova/lib) gives the following output:

"iPhone Retina (3.5-inch)"
"iPhone Retina (4-inch)"
"iPhone Retina (4-inch 64-bit)"
"iPhone"
"iPad"
"iPad Retina"

However, the thing is: I can't seem to figure out how to start the emulator in anything other than the default (which appears to be the iPhone Retina (4-inch) emulation image). The relevant output of cordova help gives the following information:

run [--debug|--release]
    [--device|--emulator|--target=FOO]
    [PLATFORM] ............................ deploys app on specified platform devices / emulators

I've tried things like the following:

cordova run --debug --emulator=iPad iOS

And many variations thereof, but no luck. Every time it starts in the same emulator.

The documentation for the command-line tool doesn't offer any information in this regard, and an extensive Google-search also failed to turn up anything. Am I missing something trivial? Or am I trying to do something weird? I really hope someone here has experience with this, and can provide some answers.

Thanks very much in advance!

edit: forgot to mention explicitly; I'm doing all this on a Mac. As mentioned earlier, running the app in different emulators/simulators in Xcode works fine.

解决方案

To find out what are the simulator images available you can use to list them

$ cordova emulate ios --list
Available iOS Virtual Devices:
    iPhone-4s, 9.3
    iPhone-5, 9.3
    iPhone-5s, 9.3
    iPhone-6, 9.3
    iPhone-6-Plus, 9.3
    iPhone-6s, 9.3
    iPhone-6s-Plus, 9.3
    iPad-2, 9.3
    iPad-Retina, 9.3
    iPad-Air, 9.3
    iPad-Air-2, 9.3
    iPad-Pro, 9.3

Then use one of the simulator names in the --target parameter:

cordova emulate ios --target="iPhone-4s, 9.3"
cordova emulate ios --target="iPad-Air-2, 9.3"
cordova emulate ios --target="iPhone-6s, 9.3"
cordova emulate ios --target="iPhone-6-Plus, 9.3"

Important Quit the simulator before launching a different target simulator (On Menu bar select Simulator->Quit)

Take into account that you may need to quit the iOS simulator via menu to switch from 3.5 to 4 inch iPhone.

dynamic list is available in platforms/ios/cordova/lib/list-emulator-images

这篇关于Cordova:启动特定iOS模拟器图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆