18

My apple developer is about to expire in 5 days. And after renewal I want to restore my devices count to 100 but meanwhile I want to export all currently added devices as backup for future use, these are 87 devices.

In new apple developer section I don't see any option to export all devices and I don't want to copy paste all 87 devices :(

Note: I want to export devices in the format required by the Apple for multiple device inserts.

Irfan DANISH
  • 7,467
  • 10
  • 35
  • 63

10 Answers10

32

If you're looking for an option that doesn't require additional software, recordings, or fiddling with regular expressions, here's a JavaScript snippet you can run in Chrome's (or I'd assume, any other browser's) JavaScript console to get a properly-formatted device list:

var ids = ["Device ID"];
var names = ["Device Name"];
$("td[aria-describedby=grid-table_name]").each(function(){
    names.push($(this).html());
});
$("td[aria-describedby=grid-table_deviceNumber]").each(function(){
    ids.push($(this).html());
});

var output = "";
for (var index = 0; index < ids.length; index++) {
    //output += names[index] + "\t" + ids[index] + "\n";    //original
    output += ids[index] + "\t" + names[index] + "\n";      //post September 2016
}
console.log(output);

The complete export will be logged to the console, at which point you can simply copy/paste it into an empty text document, which can then be re-imported back to Apple at any time.

This works with Apple's current developer site layout, as of April 2015. Obviously it may break if they change stuff.

aroth
  • 51,522
  • 20
  • 132
  • 168
  • Its jQuery code, don't you think we have to include jQuery library and then execute above code. ? – Irfan DANISH Apr 03 '15 at 10:14
  • @IrfanDANISH - No, jQuery will already have been included by Apple, assuming that you're running this code in a JavaScript console on Apple's provisioning portal to extract the list of device id's. I can't really think of any other context in which the snippet would be useful. – aroth Apr 03 '15 at 12:05
  • 1
    As of September 2016, you need to switch names and ids on the output += line. Ids first. Then name. Otherwise it won't work. Awesome answer btw! – Jan Sep 21 '16 at 18:58
14

As of March 2021 this snippet that I have created (mixture of T.Nhan's answer above and Apple guidelines of upload format) works out of the box by just saving output in a .txt file and upload:

var data = document.querySelectorAll(".infinite-scroll-component .row");

var deviceListString = "Device ID\tDevice Name\tDevice Platform\n"
for (var i = 1; i < data.length; i++) {
  deviceListString += (data[i].childNodes[1].innerText + "\t" + data[i].childNodes[0].innerText + "\t" + (data[i].childNodes[2].innerText == "iPhone" || data[i].childNodes[2].innerText == "iPad" || data[i].childNodes[2].innerText == "Apple Watch" ? "ios" : "mac") + "\n");
}

console.log(deviceListString);
Burak Kurkcu
  • 440
  • 4
  • 8
9

Open list of devices safari, chrome or firefox&firebug. Open web inspector (opt-cmd-i in safari), go to instrument tab (ctrl+3). Press "Start Recording" button and refresh page.

In the very bottom of the appeared list find "listDevices.action" and select it. In the right column of a web inspector copy & paste full URL and download JSON file with a list of devices. Then, with a simple regexp (i.e. /\"name\": \"([^\"]+)\",\n\s*\"deviceNumber\": \"([^\"]+)\"/ ) you can get devices' name and number.

Format that Apple accepts for upload is

Device ID   Device Name
A123456789012345678901234567890123456789    NAME1
B123456789012345678901234567890123456789    NAME2

Update:
Ah! Apple now provides a full deviceNumber on "iOS devices" page, so it makes whole process easier. Copy-paste the list in, for example, Sublime text and put devices' name and number in a proper order:

find: /^(.*) +([^\n]+)\n/
replace: \2\t\1\n

kovpas
  • 9,617
  • 6
  • 36
  • 42
  • thanx, your solution is good and working. Don't you think apple should give simple export feature to developers :) – Irfan DANISH Apr 17 '13 at 07:13
  • You're welcome :). Re your question. To be honest, I don't see this feature is really necessary - you might only need it in case of account migration, which is not a usual case. – kovpas Apr 17 '13 at 07:37
  • 2
    That regexp did not do it for me. Finally came up with `(.*\s)(\w+)$` and replace: `\2\t\1` – Hjalmar Nov 10 '14 at 13:35
6

You can use a command tool call Spaceship, it exposes both the Apple Developer Center and the iTunes Connect API

Here is how I did to migrate all my devices from my Apple Developer account to a second one.

spaceship1 = Spaceship::Launcher.new("account1@email.com", "password")
spaceship2 = Spaceship::Launcher.new("account2@email.com", "password")

#Get all devices from the Apple Developer account 1.
devices = spaceship1.device.all

#Loop through all devices from account 1 and then add/create them in account2.
devices.each do |device| spaceship2.device.create!(name: device.name, udid: device.udid) end

Note: To quickly play around with spaceship launch irb in your terminal and execute require "spaceship".

gbg_sw4gger
  • 61
  • 1
  • 6
5

None of the above worked for me, most likely because Apple changed the format. But what did work perfectly was the following:

  • copy/paste all the items from Apple's devices page
  • paste into Numbers, device ID and names are recognised as 2 distinct columns
  • drag the column order so devices are first rather than names
  • copy/paste all rows into a text file
  • upload to Apple and you're done
Demian Turner
  • 406
  • 3
  • 10
2

Looks like the webpage structure has been edited a little since the latest response. My new snippet also formats the output as CSV, so you can save the output and open it with Numbers/Excel and share it.

var data = document.querySelectorAll(".infinite-scroll-component .row");
var csvOutput = "Name, Identifier, Type\n"

for (var i = 1; i < data.length; i++) {
    let name = data[i].childNodes[0].childNodes[0].textContent;
    let identifier = data[i].childNodes[1].childNodes[0].textContent;
    let type = data[i].childNodes[2].childNodes[0].textContent;
    let device = [name, identifier, type].join(", ") + "\n";
    csvOutput += device;
}

console.log(csvOutput);
Behdad
  • 832
  • 11
  • 22
1

Check out Mattt's command line interface tool, Cupertino

You can run ios devices:list to get the list of devices on your account.

It probably isn't the exact format for Apple's importer, but it should get you to a good point, there is also ios devices:add that will let you re-add your devices from the command line.

Chris Wagner
  • 20,295
  • 8
  • 70
  • 94
  • 1
    Great tool, but it doesn't work anymore :( `Due to an update by Apple to the Dev Center on April 7th, the current version of Cupertino does not work. For lack of a public API, Cupertino relied on screen-scraping to get its information, so a change in the structure of the site breaks the functionality of the CLI. We are working quickly to restore compatibility with the next release. Thanks for your patience.` – kovpas Apr 17 '13 at 06:45
  • I totally missed that :( hopefully they get it fixed soon. – Chris Wagner Apr 17 '13 at 06:49
1

Nowaday, Apple doesn't have JQuery anymore. We can use this query to get

var data = document.querySelectorAll(".infinite-scroll-component .row");
for(var i = 0 ; i < dencho.length; i++){
  var name =  data[i].childNodes[0];
  var id =  data[i].childNodes[1]
  console.log(name.innerText + "\t" +  id.innerText  + "\n");
}
T.Nhan
  • 168
  • 1
  • 9
0

My solution to this was to create new provisioning profile here and add all devices to it. Then download it and open with vim (or any other editor). The file will contain some binary style and plist (xml) with all your devices, which can be parsed I guess, but I just c&p device list. Smth like:

<key>ProvisionedDevices</key>
   <array>
       <string>device1 udid</string>
       ....
       <string>deviceN udid</string>
   </array>

Delete your provisioning profile if you don't need it after.

waggledans
  • 931
  • 7
  • 7
0

In my case, I also want to get the device model (ex, iPhone X, iPhone 8....) You can get any device info base on UDID with object var object = JSON.parse(this.responseText);

var data = document.querySelectorAll(".infinite-scroll-component .row");
var deviceListString = ""
var databody = JSON.stringify({
  teamId: 'XXXXXXXX' // your team id here
})

for (var i = 1; i < data.length; i++) {
    var xhr = new XMLHttpRequest()
    xhr.withCredentials = true
    xhr.addEventListener('readystatechange', function() {
        if (this.readyState === this.DONE) {
            var object = JSON.parse(this.responseText);
            deviceListString += object.data.attributes.name + "\t" + object.data.attributes.model + "\t" +object.data.attributes.udid + "\n";
        }
    })

    var rowID = data[i].getAttribute('data-id');
    var url = `https://developer.apple.com/services-account/v1/devices/${rowID}?fields[devices]=name,udid,platform,model,status,devicePlatformLabel`
    xhr.open('POST', url);
    xhr.setRequestHeader('content-type', 'application/vnd.api+json');
    xhr.setRequestHeader('x-http-method-override', 'GET');
    xhr.send(databody);
}

When you type enter, the result was stored in deviceListString So just get that value

deviceListString

This is screenshot: enter image description here

eric long
  • 464
  • 4
  • 13