How can I find the device uuid's of all connected devices through a command line script?
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!
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
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'
install ideviceinstaller on Mac OS X via brew command:
brew install ideviceinstaller
then idevice_id -l
will work from terminal
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