Skip to content

Instantly share code, notes, and snippets.

@andrewgrant
Created August 19, 2019 19:58
Show Gist options
  • Save andrewgrant/f842d87f48c4d54256e8d37c6d0d9f95 to your computer and use it in GitHub Desktop.
Save andrewgrant/f842d87f48c4d54256e8d37c6d0d9f95 to your computer and use it in GitHub Desktop.
Fastlane script that pulls all devices from one or more apple accounts, dedupes them, and writes them to a csv
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
require 'spaceship'
default_platform(:ios)
platform :ios do
desc "Pulls a list of all devices from our accounts and dedupes them "
lane :dump_devices do
device_list = {}
launcher = Spaceship::Launcher.new("user@foo.com", "password")
teams = ["ABCDE12345", "ABCDE12345", "ABCDE12345"]
teams.each { |team|
# select_team will prompt for a team, unless we set this var first...
# (either way it needs to be called to update internal state)
team_id team
launcher.select_team()
devices = launcher.device.all
#Loop through all devices from account and add them to our hash
devices.each { |device|
if !device_list.has_key? device.udid
device_list[device.udid] = device
end
}
}
open('device_list.csv', 'w') { |f|
device_list.each do |key, device|
f.printf("%s|%s|%s|%s\n", device.udid, device.name, device.platform, device.model)
end
printf("Wrote %d devices", device_list.keys.count)
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment