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

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

问题描述

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

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

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

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

这工作正常,并导致 iOS 模拟器在带有 iOS 7.0.3 的模拟 iPhone 4 Retina 中运行我的应用

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

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

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"

然而,问题是:我似乎无法弄清楚如何在默认情况下启动模拟器(这似乎是 iPhone Retina (4-inch) 仿真图像).cordova help 的相关输出提供了以下信息:

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

我尝试过以下操作:

cordova run --debug --emulator=iPad iOS

还有很多变种,但没有运气.每次都在同一个模拟器中启动.

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

该命令的文档-line 工具没有提供这方面的任何信息,广泛的谷歌搜索也没有找到任何信息.我错过了一些微不足道的东西吗?还是我想做一些奇怪的事情?我真的希望这里有人有这方面的经验,并且可以提供一些答案.

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.

非常感谢!

忘记明确提及;我在 Mac 上做这一切.如前所述,在 Xcode 中的不同模拟器/模拟器中运行应用程序可以正常工作.

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

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

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"

重要在启动不同的目标模拟器之前退出模拟器(在菜单栏上选择Simulator->退出)

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

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

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

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

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

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