Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. I tried using wget:

  1. Logged in to https://developer.apple.com/account
  2. Then went here 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
  4. I tried to $ wget http://adcdownload.apple.com/Developer_Tools/Xcode_8/Xcode_8.xip but I only got this on the terminal:

    --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. 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 request sent, awaiting response... 200 OK Length: 2070 (2.0K) [text/html] Saving to: ‘Xcode_8.xip’

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

    2016-09-21 15:13:18 (85.8 MB/s) - ‘Xcode_8.xip’ saved [2070/2070]

like image 411
mownier Avatar asked Sep 21 '16 07:09

mownier


3 Answers

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. The way around is using wget but it fails by default because those cookies are missing. The solution is to export the cookies from a browser and then use them along with wget as follows.

For example downloading XCode 9 beta from developer account copy the XCode 9 download url and use wget as follows.

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. I use chrome browser and cookies.txt is a decent option. 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.

like image 144
dannysood Avatar answered Oct 07 '22 23:10

dannysood


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). 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)
  2. Run the script through terminal (ruby filename.rb)
  3. Get cookie from chrome
    -Open https://developer.apple.com/download/more/
    -Open developer tools -> 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
like image 35
Ammar Mujeeb Avatar answered Oct 08 '22 01:10

Ammar Mujeeb


To have the download resume when your connection drops, use Safari to download it. 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.

like image 25
Robin Daugherty Avatar answered Oct 08 '22 01:10

Robin Daugherty