【问题标题】:Export devices added in Apple's iOS Provision portal在 Apple 的 iOS Provision 门户中添加的导出设备
【发布时间】:2013-04-09 18:55:59
【问题描述】:

我的苹果开发者将在 5 天后到期。续订后,我想将我的设备数量恢复到 100,但同时我想导出所有当前添加的设备作为备份以备将来使用,这些是 87 台设备。

在新的苹果开发者部分,我没有看到任何导出所有设备的选项,我不想复制粘贴所有 87 台设备:(

注意: 我想以 Apple 要求的多设备插入格式导出设备。

【问题讨论】:

    标签: iphone iphone-developer-program


    【解决方案1】:

    如果您正在寻找一个不需要额外软件、记录或修改正则表达式的选项,这里有一个 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 当前的开发人员网站布局。显然,如果他们更改内容,它可能会中断。

    【讨论】:

    • 它的jQuery代码,你不认为我们必须包含jQuery库然后执行上面的代码。 ?
    • @IrfanDANISH - 不,Apple 已经包含了 jQuery,假设您在 Apple 供应门户上的 JavaScript 控制台中运行此代码以提取设备 ID 列表。我真的想不出任何其他可以使用 sn-p 的上下文。
    • 截至 2016 年 9 月,您需要在输出 += 行上切换名称和 ID。先说身份证。然后命名。否则它将无法正常工作。顺便说一句,很棒的答案!
    【解决方案2】:

    截至 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);

    【讨论】:

    • 这对我有用,没有任何问题。这里的其他解决方案已经过时了。
    • 它有效。谢谢!
    【解决方案3】:

    打开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

    【讨论】:

    • thanx,您的解决方案很好并且有效。你不认为苹果应该给开发者简单的导出功能吗:)
    • 不客气 :)。回复你的问题。老实说,我不认为这个功能真的很有必要——你可能只在帐户迁移的情况下才需要它,这不是通常的情况。
    • 那个正则表达式没有为我做。终于想出了(.*\s)(\w+)$ 并替换:\2\t\1
    【解决方案4】:

    您可以使用名为 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"。

    【讨论】:

      【解决方案5】:

      以上方法都不适合我,很可能是因为 Apple 更改了格式。但完美的工作如下:

      • 复制/粘贴 Apple 设备页面中的所有项目
      • 粘贴到数字中,设备 ID 和名称被识别为 2 个不同的列
      • 拖动列顺序,使设备排在第一位,而不是名称排在第一位
      • 将所有行复制/粘贴到文本文件中
      • 上传到 Apple 就完成了

      【讨论】:

        【解决方案6】:

        现在,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");
        }

        【讨论】:

          【解决方案7】:

          自最新回复以来,网页结构似乎已进行了一些修改。我的新 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);

          【讨论】:

            【解决方案8】:

            查看Mattt's命令行界面工具,Cupertino

            您可以运行ios devices:list 以获取您帐户中的设备列表。

            它可能不是 Apple 导入器的确切格式,但它应该让你明白,还有 ios devices:add 可以让你从命令行重新添加你的设备。

            【讨论】:

            • 很棒的工具,但它不再工作了:( 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.
            • 我完全错过了 :( 希望他们能尽快修复它。
            【解决方案9】:

            我的解决方案是创建新的配置文件here 并将所有设备添加到其中。然后下载它并用 vim(或任何其他编辑器)打开。该文件将包含所有设备的一些二进制样式和 plist (xml),我猜可以解析,但我只是 c&p 设备列表。喜欢:

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

            如果之后不需要,请删除您的配置文件。

            【讨论】:

              【解决方案10】:

              就我而言,我还想获取设备型号(例如,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
              

              这是截图:

              【讨论】:

                猜你喜欢
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 2017-05-05
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                相关资源
                最近更新 更多