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

IphoneIosUuid

Iphone Problem Overview


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.

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

Thanks!

Iphone Solutions


Solution 1 - Iphone

Edit:

instruments command is now deprecated, you should run instead

xcrun xctrace list devices

Previous answer:

If you have Xcode installed, you can use Instruments to get all known devices also. With

instruments -s devices

Solution 2 - Iphone

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

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

Solution 3 - Iphone

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

then idevice_id -l will work from terminal

Solution 4 - Iphone

I found a similar question about using multiple devices here 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 $2}'); 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

Solution 5 - Iphone

Also ios-deploy can be used:

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

Solution 6 - Iphone

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSirRupertIIIView Question on Stackoverflow
Solution 1 - IphoneQuanlongView Answer on Stackoverflow
Solution 2 - IphoneJay LieskeView Answer on Stackoverflow
Solution 3 - IphoneShiva Krishna ChippaView Answer on Stackoverflow
Solution 4 - IphoneSirRupertIIIView Answer on Stackoverflow
Solution 5 - IphoneDegardView Answer on Stackoverflow
Solution 6 - IphoneRiversView Answer on Stackoverflow