关于rubygems:Calabash-ios 控制台无法启动 DEVICE_TARGET=’iPhone 5 (9.2)’

Calabash-ios console can't start with DEVICE_TARGET='iPhone 5 (9.2)'

我正在尝试启动测试服务器,但出现以下错误。
请有人给我解决方案。我尝试了 gem 版本的不同组合,但没有运气。
感谢您对此的快速帮助。

我正在使用类似

的命令

1
2
3
4
DEVICE_TARGET='iPhone 5 (9.2)' calabash-ios console


irb(main):001:0> start_test_server_in_background

ArgumentError: Could not find a device with a UDID or name matching 'iPhone'
from /Users/test/.rvm/gems/ruby-2.0.0-p353/gems/run_loop-2.1.1/lib/run_loop/device.rb:126:in device_with_identifier'
from /Users/test/.rvm/gems/ruby-2.0.0-p353/gems/run_loop-2.1.1/lib/run_loop/device.rb:160:in
detect_device'
from /Users/test/.rvm/gems/ruby-2.0.0-p353/gems/run_loop-2.1.1/lib/run_loop/core.rb:71:in run_with_options'
from /Users/test/.rvm/gems/ruby-2.0.0-p353/gems/run_loop-2.1.1/lib/run_loop.rb:134:in
run'
from /Users/test/.rvm/gems/ruby-2.0.0-p353/gems/calabash-cucumber-0.18.1/lib/calabash-cucumber/launcher.rb:718:in block in new_run_loop'
from /Users/test/.rvm/gems/ruby-2.0.0-p353/gems/calabash-cucumber-0.18.1/lib/calabash-cucumber/launcher.rb:716:in
times'
from /Users/test/.rvm/gems/ruby-2.0.0-p353/gems/calabash-cucumber-0.18.1/lib/calabash-cucumber/launcher.rb:716:in new_run_loop'
from /Users/test/.rvm/gems/ruby-2.0.0-p353/gems/calabash-cucumber-0.18.1/lib/calabash-cucumber/launcher.rb:584:in
relaunch'
from /Users/test/.rvm/gems/ruby-2.0.0-p353/gems/calabash-cucumber-0.18.1/lib/calabash-cucumber/core.rb:943:in start_test_server_in_background'
from (irb):1
from /Users/test/.rvm/rubies/ruby-2.0.0-p353/bin/irb:12:in
'


更新

从您的评论来看,您似乎是在尝试在物理设备上启动,而不是在模拟器上启动。这令人困惑,因为"iPhone 5 (9.2)"与模拟器具有相同的命名约定。

当你定位一个物理设备时,你需要使用设备的UDID,你可以在instruments的前几行输出中找到它:

1
2
3
4
5
6
$ xcrun instruments -s devices
stern [4AFA58C7-5D39-54D0-9733-04302E7XXXXX]
neptune (9.3.1) [43be3f89d9587e9468c24672777ff6241bdXXXXX]
uranus (9.3.1) [6c3ed5434b5dfc29758f8835644b55bd43XXXXX]
Apple TV 1080p (9.0) [D6875A98-2C0E-4138-85EF-841025A54DE0] (Simulator)
# the rest are simulators.

在上面的例子中:

1
2
* stern is the host computer.
* neptune and uranus are physical devices.

瞄准海王星:

1
2
3
$ DEVICE_TARGET=43be3f89d9587e9468c24672777ff6241bdXXXXX \\
  DEVICE_ENDPOINT=http://<ip of your device>:37265 \\
  calabash-ios console

如果您合理地命名您的设备,您也可以这样做:

1
2
3
$ DEVICE_TARGET=neptune \\
  DEVICE_ENDPOINT=http://<ip of your device>:37265 \\
  calabash-ios console

我怀疑由于您的物理设备名称与模拟器名称完全匹配,Calabash 对您要定位的设备感到困惑。

回顾一下:你有两个选择:

1
2
3
4
5
6
7
8
9
 1. Use the UDID you get from instruments.
 $ DEVICE_TARGET=43be3f89d9587e9468c24672777ff6241bdXXXXX \\
   DEVICE_ENDPOINT=http://<ip of your device>:37265 \\
   calabash-ios console

 2. Rename your device to something like"iphone5"
 $ DEVICE_TARGET=iphone5 \\
   DEVICE_ENDPOINT=http://<ip of your device>:37265 \\
   calabash-ios console

您可能会发现物理设备上的测试 wiki 页面很有帮助。

上一个答案

你试过"引号吗?

1
$ DEVICE_TARGET="iPhone 5 (9.2)" calabash-ios console

ArgumentError: Could not find a device with a UDID or name matching 'iPhone' from

由于某种原因,run-loop 缺少字符串的 "5 (9.2)" 部分。

我唯一能想到的另一件事是您没有安装 iPhone 5 iOS 9.2 模拟器。你在 Xcode 中看到了吗?

您也可以尝试直接使用 UDID。

1
2
3
4
5
6
7
# List the available simulators
$ xcrun instruments -s devices
<snip>
iPhone 6 Plus (9.3) [D6AFEDFE-2E02-4A33-AEC8-740053DDC6DE] (Simulator)

 # Use the UDID directly.
 $ DEVICE_TARGET="D6AFEDFE-2E02-4A33-AEC8-740053DDC6DE" calabash-ios console