Search code examples
iosappiuminstruments

How to get iOS version of a device from command line?


I was trying to find a way to get iOS version of a device from command line, like adb devices in Android, but I couldn't find any solution. All the answers I found were explaining how to obtain it from application.

Is there any way to get iOS version of a device/devices from command line?

Thanks


Solution

  • After some research, I found that instruments has instruments -s devices command.

    When you run the command, it will list all Known Devices, but the ones connected will be on top of the list with their Serial Number.

    A similar output is that:

    admin$ instruments -s devices
    Known Devices:
    test iPhone (v7.1.1) (deviceserialnumber)
    test iPhone 5S (v7.1.1) (deviceserialnumber)
    iPhone - Simulator - iOS 7.1
    iPhone Retina (3.5-inch) - Simulator - iOS 7.1
    iPhone Retina (4-inch) - Simulator - iOS 7.1
    

    I used sed command to get only Serial Number and iOS Version:

    instruments -s devices | sed -n -E -e 's/.*v(.*)\) \((.*)\)/\2 \1/p'
    

    And the output will be:

    deviceserialnumber 7.1.1
    deviceserialnumber 7.1.1