【问题标题】:How can i get active ios device or simulator UDID?如何获得活动的 ios 设备或模拟器 UDID?
【发布时间】:2017-10-16 11:51:08
【问题描述】:

我可以通过“instruments -s device”获取所有可用的设备

我无法确定哪个是活动设备。如何在 JAVA 中以编程方式识别活动设备或模拟器。

请帮帮我。

谢谢。

【问题讨论】:

  • 嗨,如果有人在寻找类似问题,这里是解决方案。 processUDID = Runtime.getRuntime().exec("xcrun simctl list devices"); BufferedReader in = new BufferedReader(new InputStreamReader( processUDID.getInputStream())); Stream<String> stream = in.lines(); stream.forEach(s -> { if (s.contains("Booted")) { String ud = deviceUdid = s.substring(s.indexOf("-") - 8) .trim(); ud = deviceUdid = ud.substring(0, ud.indexOf(")")).trim(); simulatorUdid = ud; } });
  • 但这并没有给出物理设备的UDID,而只有模拟器

标签: java iphone xcode instruments xcode-instruments


【解决方案1】:
$ xcrun simctl list devices | grep 'Booted'
iPhone 5 (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX) (Booted)

【讨论】:

  • 这不显示连接的物理设备,只显示iOS模拟器
【解决方案2】:

这不是按照最初的要求在 JAVA 中以编程方式完成的,但可能会对某人有所帮助。

要获取所有活动的 iOS 物理设备和 iOS 模拟器及其 UDID:

$ xcrun xctrace list devices

要找到 活动的 iOS 模拟器及其 UDID:

$ xcrun simctl list | grep Booted

【讨论】:

    猜你喜欢
    • 2018-08-02
    • 1970-01-01
    • 1970-01-01
    • 2013-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多