【发布时间】:2013-04-09 18:55:59
【问题描述】:
我的苹果开发者将在 5 天后到期。续订后,我想将我的设备数量恢复到 100,但同时我想导出所有当前添加的设备作为备份以备将来使用,这些是 87 台设备。
在新的苹果开发者部分,我没有看到任何导出所有设备的选项,我不想复制粘贴所有 87 台设备:(
注意: 我想以 Apple 要求的多设备插入格式导出设备。
【问题讨论】:
标签: iphone iphone-developer-program
我的苹果开发者将在 5 天后到期。续订后,我想将我的设备数量恢复到 100,但同时我想导出所有当前添加的设备作为备份以备将来使用,这些是 87 台设备。
在新的苹果开发者部分,我没有看到任何导出所有设备的选项,我不想复制粘贴所有 87 台设备:(
注意: 我想以 Apple 要求的多设备插入格式导出设备。
【问题讨论】:
标签: iphone iphone-developer-program
如果您正在寻找一个不需要额外软件、记录或修改正则表达式的选项,这里有一个 JavaScript sn-p,您可以在 Chrome(或者我假设,任何其他浏览器的)JavaScript 中运行控制台获取格式正确的设备列表:
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);
完整的导出将记录到控制台,此时您可以简单地将其复制/粘贴到一个空的文本文档中,然后可以随时将其重新导入回 Apple。
截至 2015 年 4 月,这适用于 Apple 当前的开发人员网站布局。显然,如果他们更改内容,它可能会中断。
【讨论】:
截至 2021 年 3 月,我创建的这个 sn-p(上面 T.Nhan 的答案和 Apple 上传格式指南的混合)只需将输出保存在 .txt 文件中并上传即可开箱即用:
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);
【讨论】:
打开list of devices safari、chrome 或 firefox&firebug。打开网络检查器(在 safari 中选择-cmd-i),转到仪器选项卡(ctrl+3)。按“开始录制”按钮并刷新页面。
在出现的列表的最底部找到“listDevices.action”并选择它。在 Web 检查器的右栏中,复制并粘贴完整的 URL 并下载带有设备列表的 JSON 文件。然后,用一个简单的正则表达式(即 /\"name\": \"([^\"]+)\",\n\s*\"deviceNumber\": \"([^\"]+)\ "/ ) 您可以获取设备的名称和编号。
Apple 接受上传的格式是
Device ID Device Name
A123456789012345678901234567890123456789 NAME1
B123456789012345678901234567890123456789 NAME2
更新:
啊! Apple 现在在“iOS 设备”页面上提供了完整的 deviceNumber,因此它使整个过程更容易。例如,将列表复制粘贴到 Sublime 文本中,并按正确顺序放置设备的名称和编号:
查找:/^(.*) +([^\n]+)\n/
替换:\2\t\1\n
【讨论】:
(.*\s)(\w+)$ 并替换:\2\t\1
您可以使用名为 Spaceship 的命令工具,它公开了 Apple Developer Center 和 iTunes Connect API
以下是我将所有设备从我的 Apple Developer 帐户迁移到第二个帐户的方法。
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
注意:要在终端中快速使用 spaceship launch irb 并执行 require "spaceship"。
【讨论】:
以上方法都不适合我,很可能是因为 Apple 更改了格式。但完美的工作如下:
【讨论】:
现在,Apple 不再有 JQuery。我们可以使用这个查询来获取
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");
}
【讨论】:
自最新回复以来,网页结构似乎已进行了一些修改。我的新 sn-p 还将输出格式化为 CSV,因此您可以保存输出并使用 Numbers/Excel 打开并共享它。
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);
【讨论】:
【讨论】:
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.
我的解决方案是创建新的配置文件here 并将所有设备添加到其中。然后下载它并用 vim(或任何其他编辑器)打开。该文件将包含所有设备的一些二进制样式和 plist (xml),我猜可以解析,但我只是 c&p 设备列表。喜欢:
<key>ProvisionedDevices</key>
<array>
<string>device1 udid</string>
....
<string>deviceN udid</string>
</array>
如果之后不需要,请删除您的配置文件。
【讨论】:
就我而言,我还想获取设备型号(例如,iPhone X、iPhone 8....)
您可以使用对象 var object = JSON.parse(this.responseText); 获取基于 UDID 的任何设备信息
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);
}
当你输入回车时,结果存储在 deviceListString 中 所以只要得到那个值
deviceListString
【讨论】: