简体   繁体   English

如何以可恢复的方式下载Xcode或其他开发者工具

[英]How to download Xcode or other developer tools in a resumable way

I have an unstable Internet connection and I need the download to be resumable.我的 Internet 连接不稳定,我需要可以恢复下载。 I tried using wget:我尝试使用 wget:

  1. Logged in to https://developer.apple.com/account登录https://developer.apple.com/account
  2. Then went here https://developer.apple.com/download/more然后去了这里https://developer.apple.com/download/more
  3. Copied the download link for Xcode 8 which is http://adcdownload.apple.com/Developer_Tools/Xcode_8/Xcode_8.xip复制 Xcode 8 的下载链接,即http://adcdownload.apple.com/Developer_Tools/Xcode_8/Xcode_8.xip
  4. I tried to $ wget http://adcdownload.apple.com/Developer_Tools/Xcode_8/Xcode_8.xip but I only got this on the terminal:我试图$ wget http://adcdownload.apple.com/Developer_Tools/Xcode_8/Xcode_8.xip但我只在终端上得到了这个:

    --2016-09-21 15:13:17-- http://adcdownload.apple.com/Developer_Tools/Xcode_8/Xcode_8.xip Resolving adcdownload.apple.com... 203.177.38.83, 203.177.38.120 Connecting to adcdownload.apple.com|203.177.38.83|:80... connected. --2016-09-21 15:13:17-- http://adcdownload.apple.com/Developer_Tools/Xcode_8/Xcode_8.xip解析 adcdownload.apple.com... 203.177.38.83, 203.177.38.120 连接到 adcdownload .apple.com|203.177.38.83|:80... 已连接。 HTTP request sent, awaiting response... 302 Moved Temporarily Location: http://developer.apple.com/unauthorized/ [following] URL transformed to HTTPS due to an HSTS policy --2016-09-21 15:13:17-- https://developer.apple.com/unauthorized/ Resolving developer.apple.com... 17.146.1.15 Connecting to developer.apple.com|17.146.1.15|:443... connected. HTTP 请求已发送,正在等待响应... 302 临时移动位置: http : //developer.apple.com/unauthorized/ [以下] 由于 HSTS 策略,URL 已转换为 HTTPS --2016-09-21 15:13:17 -- https://developer.apple.com/unauthorized/ 正在解析 developer.apple.com... 17.146.1.15 连接到 developer.apple.com|17.146.1.15|:443... 已连接。 HTTP request sent, awaiting response... 200 OK Length: 2070 (2.0K) [text/html] Saving to: 'Xcode_8.xip' HTTP 请求已发送,正在等待响应... 200 OK 长度:2070 (2.0K) [text/html] 保存到:'Xcode_8.xip'

    Xcode_8.xip 100%[==================================>] 2.02K --.-KB/s in 0s Xcode_8.xip 100%[==================================>] 2.02K --.-KB/ s 为 0

    2016-09-21 15:13:18 (85.8 MB/s) - 'Xcode_8.xip' saved [2070/2070] 2016-09-21 15:13:18 (85.8 MB/s) - 'Xcode_8.xip' 已保存 [2070/2070]

Apple developer account downloads are tracked using browser cookies to check their validity and the download is flaky and fails quite regularly especially on a slower internet connection.使用浏览器 cookie 跟踪 Apple 开发者帐户下载以检查其有效性,并且下载不稳定且经常失败,尤其是在较慢的互联网连接上。 The way around is using wget but it fails by default because those cookies are missing.解决方法是使用 wget 但默认情况下它会失败,因为这些 cookie 丢失了。 The solution is to export the cookies from a browser and then use them along with wget as follows.解决方案是从浏览器中导出 cookie,然后将它们与 wget 一起使用,如下所示。

For example downloading XCode 9 beta from developer account copy the XCode 9 download url and use wget as follows.例如从开发者帐户下载 XCode 9 beta 复制 XCode 9 下载 url 并使用 wget 如下。

wget --load-cookies=cookies.txt -c https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_9_beta_6/Xcode_9_beta_6.xip

This should start downloading in the same directly as it is run and in case it cancels or fails because of flaky connection just run the same command again in the same directory as before and it should resume just fine.这应该在运行时直接开始下载,如果由于连接不稳定而取消或失败,只需在与以前相同的目录中再次运行相同的命令,它应该可以正常恢复。

There are a lot of different ways to export cookies from the browser.有很多不同的方法可以从浏览器中导出 cookie。 I use chrome browser and cookies.txt is a decent option.我使用 chrome 浏览器, cookies.txt是一个不错的选择。 I in no way endorse this product and many other solutions in different browsers should work just as well.我绝不认可这个产品,不同浏览器中的许多其他解决方案也应该同样有效。 A quick google should help.一个快速的谷歌应该会有所帮助。 NOTE: for some reason cookies.txt only works if I only export cookies for the developer.apple.com website and doesnt work if I export all cookies from browser.注意:出于某种原因,cookies.txt 仅在我只为 developer.apple.com 网站导出 cookie 时才有效,如果我从浏览器中导出所有 cookie,则它不起作用。

To have the download resume when your connection drops, use Safari to download it.要在连接断开时恢复下载,请使用 Safari 进行下载。 It correctly resumes downloads after the connection is restored and you click the orange "Resume downloading" icon next to the download.连接恢复后,它会正确恢复下载,您单击下载旁边的橙色“恢复下载”图标。

I just tested this with Safari 11 to be certain, but I've used Safari's ability to resume downloads from Apple Developer for about 12 years now.我刚刚用 Safari 11 对此进行了测试,以确认这一点,但我已经使用 Safari 的功能从 Apple Developer 恢复下载大约 12 年了。

I was able to download the Xcode xip file in just 18 mins that would take 2-3 hours on the internet speed i have by following this blog link (credits to the author).我能够在 18 分钟内下载 Xcode xip 文件,这在我拥有的互联网速度上需要 2-3 小时,请点击此博客链接(作者致谢)。 Moreover, it resumed automatically after getting internet again.而且,它在再次上网后自动恢复。 For simplifying i am listing the steps.为了简化,我列出了步骤。

  1. Save the script mentioned at the link in a file (filename.rb)链接中提到的脚本保存在文件 (filename.rb) 中
  2. Run the script through terminal (ruby filename.rb)通过终端运行脚本(ruby filename.rb)
  3. Get cookie from chrome从 chrome 获取 cookie
    -Open https://developer.apple.com/download/more/ - 打开https://developer.apple.com/download/more/
    -Open developer tools -> Cookies -> ADCDownloadAUTH - 打开开发者工具 -> Cookies -> ADCDownloadAUTH
    -Copy this Cookie and pass this cookie in input (when script will ask) and URL URL: https://download.developer.apple.com/Developer_Tools/Xcode_10.2/Xcode_10.2.xip - 复制此 Cookie 并在输入中传递此 cookie(当脚本询问时)和 URL URL: https ://download.developer.apple.com/Developer_Tools/Xcode_10.2/Xcode_10.2.xip

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM