Skip to content

Instantly share code, notes, and snippets.

@0xack13
Last active April 30, 2025 13:54
Show Gist options
  • Save 0xack13/6ef0b239229b43c3b0119f0d9b4f0982 to your computer and use it in GitHub Desktop.
Save 0xack13/6ef0b239229b43c3b0119f0d9b4f0982 to your computer and use it in GitHub Desktop.
extract_devices
require 'xcresult'
xcresult_path = 'path/to/your/Test.xcresult'
parser = XCResult::Parser.new(xcresult_path)
# This gives you the top-level parsed object
result = parser.parse
# You can now access test summaries in a nice structure
result.action_test_plan_run_summaries.each do |plan_summary|
plan_summary.testable_summaries.each do |testable|
target_name = testable.target_name
# Optional: You could also try to get device from the first test
device_identifier = testable.tests&.first&.device_identifier
puts "Target Name: #{target_name}"
puts "Device Identifier: #{device_identifier}"
# Derive platform from target or device identifier
platform =
if target_name.downcase.include?("ipad") || device_identifier.to_s.downcase.include?("ipad")
"ipad"
elsif target_name.downcase.include?("iphone") || device_identifier.to_s.downcase.include?("iphone")
"iphone"
else
"unknown"
end
puts "Platform: #{platform}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment