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

时间:2015-03-24 17:02:19

标签: ios cordova mobile command-line-interface

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

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时(通过'退出',' 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运行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'

1 个答案:

答案 0 :(得分:12)

您好我是离子显影剂,但我明显使用了cordova。 让我试着帮助你。

Privet Sergey!

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

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

ios-deploy -c

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

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

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