ios 如何通过命令行脚本找到所有连接设备的设备 uuid?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17237354/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 00:01:43  来源:igfitidea点击:

How can I find the device uuid's of all connected devices through a command line script?

iphoneiosuuid

提问by SirRupertIII

I am running automated tests on iOS devices. I want to not have to always have all devices connected. So I want to find all device id's and then only start the process of building, deploying, and running tests if that device is connected.

我正在 iOS 设备上运行自动化测试。我不想总是连接所有设备。因此,我想找到所有设备 ID,然后仅在该设备已连接时才开始构建、部署和运行测试的过程。

So my question is, how can I find the device uuid's of all connected devices through a shell script?

所以我的问题是,如何通过 shell 脚本找到所有连接设备的设备 uuid?

Thanks!

谢谢!

回答by Quanlong

If you have Xcodeinstalled, you can use Instrumentsto get all known devices also. With

如果您安装了Xcode,您也可以使用Instruments来获取所有已知设备。和

instruments -s devices

回答by Jay Lieske

The answer from @KKendall set me on the right path. Here's a version with a single sed expression:

@KKendall 的回答让我走上了正确的道路。这是一个带有单个 sed 表达式的版本:

system_profiler SPUSBDataType | sed -n -E -e '/(iPhone|iPad)/,/Serial/s/ *Serial Number: *(.+)//p'

回答by Shiva krishna Chippa

install ideviceinstalleron Mac OS X via brew command: brew install ideviceinstaller

通过 brew 命令在 Mac OS X 上安装ideviceinstallerbrew install ideviceinstaller

then idevice_id -lwill work from terminal

然后idevice_id -l将从终端工作

回答by SirRupertIII

I found a similar question about using multiple deviceshere is my form of the answer that helped me:

我在这里发现了一个关于使用多个设备的类似问题,这是对我有帮助的答案形式:

 #!/bin/sh
 i=0
 for line in $(system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p' -e '/iPhone/,/Serial/p' | grep "Serial Number:" | awk -F ": " '{print }'); do
    UDID=${line}
    echo $UDID
    udid_array[i]=${line}
    i=$(($i+1))
 done

 cnt=${#udid_array[@]}
 for ((i=0;i<cnt;i++)); do
    echo ${udid_array[i]}
 done

回答by Degard

Also ios-deploycan be used:

也可以使用ios-deploy

ios-deploy -c | grep -oE 'Found ([0-9A-Za-z\-]+)' | sed 's/Found //g'

回答by Rivers

If you have XCode go to Window > Devices & Simulators. On that page, any connected device will display along with other IDs and stats on your device. This will also connect to devices over WIFI.

如果您有 XCode,请转到 Window > Devices & Simulators。在该页面上,任何连接的设备都将与您设备上的其他 ID 和统计信息一起显示。这也将通过 WIFI 连接到设备。