Created
March 19, 2018 11:53
-
-
Save saitjr/29950548caf8772763d3301e76a8bf4c to your computer and use it in GitHub Desktop.
Export Developer Devices as deviceids
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run `gem install plist` first | |
require 'plist' | |
file_path = ARGV[0] | |
map = {} # 用于过滤 | |
File.open(file_path, "r").each do |line| | |
infos = line.split("\t") | |
next if infos.count != 2 | |
device_name, device_id = infos | |
device_name = device_name.chomp.strip | |
device_id = device_id.chomp.strip | |
map[device_id] = device_name | |
end | |
result = [] # 用于存储输出到 plist 里面的值 | |
map.each do |k, v| | |
item = { | |
"deviceIdentifier" => k, | |
"deviceName" => v | |
} | |
result << item | |
end | |
content = { | |
"Device UDIDs" => result | |
} | |
p result.count | |
File.open(File.join(File.dirname(file_path), "result.deviceids"), "w") do |f| | |
f.write(content.to_plist) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment