Skip to content

Instantly share code, notes, and snippets.

@eryshkov
Created October 6, 2021 20:46
Show Gist options
  • Save eryshkov/3e1735b7d1a1b7ddf6cd7dd923e43ecd to your computer and use it in GitHub Desktop.
Save eryshkov/3e1735b7d1a1b7ddf6cd7dd923e43ecd to your computer and use it in GitHub Desktop.
xcode faster download
#!/usr/bin/env ruby
print "What is the URL of your Apple Downloads resource?\nURL:"
url = gets.strip
print "What is the ADCDownloadAuth cookie token:\nADCDownloadAuth: "
token = gets.strip
command = <<~SHELL
aria2c \
--header "Host: adcdownload.apple.com" \
--header "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" \
--header "Upgrade-Insecure-Requests: 1" \
--header "Cookie: ADCDownloadAuth=#{token}" \
--header "User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 10_1 like Mac OS X) AppleWebKit/602.2.14 (KHTML, like Gecko) Version/10.0 Mobile/14B72 Safari/602.1" \
--header "Accept-Language: en-us" \
--max-connection-per-server=16 \
--split=16 \
-d ~/Downloads \
--continue=true \
#{url}
SHELL
exec(command)
@eryshkov
Copy link
Author

eryshkov commented Oct 6, 2021

Forget Mac App Store, use Apple Developer Portal

Downloading Xcode from the Apple Developer Portal is faster than using the Mac App Store, but it can be made even better.
You just need to use the right tools.
Install aria2 from Homebrew and use this script.

@eryshkov
Copy link
Author

eryshkov commented Oct 6, 2021

RUN:
ruby xcode.dw.sh

@eryshkov
Copy link
Author

eryshkov commented Oct 6, 2021

Faster install with xip and deleting previous Xcode first.

When you install the Xcode xip file you need to extract it. You can double click it in Finder and wait or you can use
xip -x Xcode11.xip
Using xip from the command line is much faster because it does not verify the file signature like double clicking in Finder. Of course this is a potential security risk, so it is up to you to decide if it is worth it.
Another trick is not to drag the extracted Xcode.app to /Applications immediately but delete the existing /Applications/Xcode.app first.
I guess this is related to Finder first getting the list of those thousands of files in the Xcode.app before the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment