I do it by making a system call to instruments, executing the, 'instruments -s devices' command and then parsing the results based on the name of the simulator.
So in Ruby, something like:
def find_uuid(device_name)
devices = `/usr/bin/instruments -s devices`
device_list = devices.split("\n")
device_list.each do |device|
match_data = /(?<device_name>.*) \((?<os>.*)\) \[(?<uuid>.*)\]/.match(device)
next if match_data.nil?
next unless match_data[:device_name].eql? device_name
return match_data[:uuid]
end
end
By creating a simple file, 'find_uuid.rb' with a few extra parameters:
#!/usr/bin/ruby
device_name = ARGV[0]
def find_uuid(device_name)
devices = `/usr/bin/instruments -s devices`
device_list = devices.split("\n")
device_list.each do |device|
match_data = /(?<device_name>.*) \((?<os>.*)\) \[(?<uuid>.*)\]/.match(device)
next if match_data.nil?
next unless match_data[:device_name].eql? device_name
return match_data[:uuid]
end
end
puts find_uuid(device_name)
I get the following output from inputting a Simulator name I have:
ruby find_uuid.rb 'iPhone4s_9.3'
401E72EB-D3C7-4390-9FEB-40374092461C
NOTE: This script is usable for real devices or simulators.