Code to fetch udid of iOS device. - SudhiHathwar/Appium-Setup-Guide GitHub Wiki
Ruby code:
#!/usr/bin/ruby deviceName = ARGV[0] def get_udid(deviceName) allDevices = `/usr/bin/instruments -s devices` deviceList = allDevices.split("\n") deviceList.each do |device| match_data = /(?<deviceName>.*) \((?<os>.*)\) \[(?<uuid>.*)\]/.match(device) next if match_data.nil? next unless match_data[:deviceName].eql? deviceName return match_data[:uuid] end end puts get_udid(deviceName)
Copy the above code in a file and save with .rb extension
To fetch udid, enter below command in terminal along with you device name (case sensitive)