如何通过CLI将Cordova应用程序部署到指定的iPhone设备?

Ser*_*rev 6 mobile command-line-interface ios cordova

我在OS X上使用最新的Cordova(4.3),我的Macbook Pro附带了2个iPhone.每当我想测试我的应用程序时,我在终端中运行以下命令:

cordova run ios --device
Run Code Online (Sandbox Code Playgroud)

该脚本在终端中生成以下输出:

** BUILD SUCCEEDED **
[....] Waiting up to 5 seconds for iOS device to be connected
[....] Found iPhone 4S 'iPhone 4S' (0b2799xxxxx) connected through USB.
[....] Found iPhone 4 (GSM) 'QA iPhone 4' (40daa94b6dc607595a570c0893ba54b185a85124) connected through USB.
[....] Waiting for iOS device to be connected
[....] Using iPhone 4S 'iPhone 4S' (0b27990xxxxxx) (0b2799xxxx).
------ Install phase ------
[  0%] Found iPhone 4S 'iPhone 4S' (0b279904xxxxxxx) connected through USB, beginning install
Run Code Online (Sandbox Code Playgroud)

然后继续在其中一个iPhone上安装应用程序,并打开lldb提示符.第二部iPhone依旧死机,无声无息.

当我退出lldb(通过'exit','y')时,脚本显示错误:

Quitting LLDB will kill one or more processes. Do you really want to proceed: [Y/n] y
Error code 253 for command: ios-deploy with args: -d,-b,/Users/path_to_app/appname.app
ERROR running one or more of the platforms: Error: /Users/path_to_app/platforms/ios/cordova/run: Command failed with exit code 2
You may not have the required environment or OS to run this project
Run Code Online (Sandbox Code Playgroud)

我查看了Cordova CLI文档和Google,但我看不出如何将应用程序部署到特定的物理iPhone设备(而不是模拟器!).在Android上,我可以使用"cordova run android --target = 06af27413440e95f",其中长号是adb中的设备ID.我如何为iPhone做到这一点?

我尝试了以下无济于事:

cordova run ios --target='QA iPhone 4'
cordova run ios --device='QA iPhone 4'
cordova run ios --device --target='QA iPhone 4'
Run Code Online (Sandbox Code Playgroud)

jev*_*per 12

嗨,我是离子开发者,但我显然使用cordova.让我试着帮助你.

Privet Sergey!

我使用的shell脚本使用可以通过使用Xcode进行部署和调试的ios-deploy节点模块.

首先运行此命令列出所有设备,你应该看到它们两个(仅供参考,使用xcode一次部署到2个设备是正常的吗?)

ios-deploy -c
Run Code Online (Sandbox Code Playgroud)

有关安装ios-deploy的信息,请参阅(https://github.com/phonegap/ios-deploy)

现在,要将命令连接并运行到特定设备,请使用以下命令:

ios-deploy  --id <device_id> --bundle my.app
Run Code Online (Sandbox Code Playgroud)

这个真棒命令行工具有快捷方式.

    Usage: ios-deploy [OPTION]...
  -d, --debug                  launch the app in GDB after installation
  -i, --id <device_id>         the id of the device to connect to
  -c, --detect                 only detect if the device is connected
  -b, --bundle <bundle.app>    the path to the app bundle to be installed
  -a, --args <args>            command line arguments to pass to the app when launching it
  -t, --timeout <timeout>      number of seconds to wait for a device to be connected
  -u, --unbuffered             don't buffer stdout
  -n, --nostart                do not start the app when debugging
  -I, --noninteractive         start in non interactive mode (quit when app crashes or exits)
  -L, --justlaunch             just launch the app and exit lldb
  -v, --verbose                enable verbose output
  -m, --noinstall              directly start debugging without app install (-d not required)
  -p, --port <number>          port used for device, default: 12345
  -r, --uninstall              uninstall the app before install (do not use with -m; app cache and data are cleared)
  -1, --bundle_id <bundle id>  specify bundle id for list and upload
  -l, --list                   list files
  -o, --upload <file>          upload file
  -w, --download               download app tree
  -2, --to <target pathname>   use together with up/download file/tree. specify target
  -V, --version                print the executable version
  -e, --exists                 check if the app with given bundle_id is installed or not
Run Code Online (Sandbox Code Playgroud)