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

How to deploy Cordova app via CLI to a specified iPhone device?

我在 OS X 上使用最新的 Cordova (4.3),我有 2 个 iPhone 连接到我的 Macbook Pro。每当我想测试我的应用程序时,我 运行 在终端中执行以下命令:

cordova run ios --device

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

** 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

然后它继续在其中一个 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

我查看了所有 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'

您好,我是离子开发人员,但我显然使用 cordova。 让我试着帮助你。

女贞德谢尔盖!

我使用 shell 脚本,该脚本使用 ios-部署节点模块,可以通过使用 Xcode.

进行部署和调试

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

ios-deploy -c

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

现在要连接特定设备并向其发送 运行ning 命令,请使用此命令:

ios-deploy  --id <device_id> --bundle my.app

这个很棒的命令行工具有快捷方式。

    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