DEV Community

Jahir Fiquitiva
Jahir Fiquitiva

Posted on

Direct download any Xcode

Downloading Xcode from the App Store, or even the .xip file while using a browser, regardless of which one it is, can be a pain when your connection is not as stable and fast as others' and when the download can be interrupted at any time and you're most likely going to have to restart the whole download.

This just happened to me and I'm writing this as a note-to-self but also to share this with others who might be facing a similar situation.

Here's what I did to download it…

1. Install Xcode Command Line Tools

It is a small package of ~183Mb which I think it's enough to be downloaded via your browser.

  • Go to Developer Downloads site
  • Sign in with your Apple ID if you need to
  • Search for the command line package you want to download (I'm going to use the latest stable Command Line tools for Xcode 10 and macOS Mojave). Command Line Tools download option
  • Press the link on the right side and wait for download to complete
  • Once downloaded, install it as any other .dmg package.

2. Install Homebrew and wget

I used Homebrew to install wget. There might be another way, but this is how I did it. 😅

  • Open Terminal
  • Run
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Enter fullscreen mode Exit fullscreen mode
  • Follow the prompted steps
  • Once done, run
brew install wget
Enter fullscreen mode Exit fullscreen mode

3. Install and get cookies.txt from your browser

  • Download for Google Chrome (Don't have a link for other browsers, sorry)
  • Visit the Developer Downloads site again.
  • Click the cookies.txt icon
  • In the top part you will see a link that says 'click here'. Click it to download the cookies.txt file
  • Save it wherever you want

4. Get Xcode direct download link

  • Visit the Developer Downloads site once more.
  • Select the Xcode version you want to download (I'm going to download Xcode 10). Xcode 10 download option
  • Right-click the link on the right side an select "Copy link address"
  • Alternatively, visit this StackOverflow answer for links to all Xcode versions.

5. Start download

  • Open Terminal and go to the location of your cookies.txt file.
  • Now run
wget --load-cookies=cookies.txt -c https://download.developer.apple.com/Developer_Tools/Xcode_10/Xcode_10.xip
Enter fullscreen mode Exit fullscreen mode
  • Replace the link at the end with the one you want for the file you want to download which you got in last step.
  • Wait for the download to finish.

Notes:

  • Add -b to the download command to run it in the background, although it is easier to check progress and state without it.
  • The -c option in the command allows you to continue with the download even if you close your terminal, or cancel the process, or restart your laptop, etc.

6. Install Xcode

  • Open the downloaded file so it starts uncompressing.
  • Move the uncompressed file to the Applications folder and you're done!

Hope you find this useful and please don't forget to share it with others!
Get to know more about me @ jahir.xyz
Image credits: unsplash.com
Originally published on medium.com

Top comments (14)

Collapse
 
dcondrey profile image
David Condrey

Install Xcode from command line

# Install Command-line tools as dependency for Homebrew
xcode-select --install # Sets the development directory path to /Library/Developer/CommandLineTools

# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Mas (command-line interface for Mac App Store)
brew install mas

# Search for Xcode showing only the first 5 results
mas search xcode | head -5
# Install Xcode using App ID
mas install 497799835 # The appid for Xcode shown when doing search

sudo xcode-select -r  # Reset the development directory path to put to Xcode /Applications/Xcode.app/Contents/Developer

#sudo xcodebuild -license

# Updaate all Apple software and auto agree to any licenses and restart if necessary
sudo softwareupdate --install --agree-to-license -aR
Enter fullscreen mode Exit fullscreen mode
Collapse
 
wookiee666 profile image
wookiee666

I had to un-comment #sudo xcodebuild -license to get it to work.

Collapse
 
mosoakinyemi profile image
Akinyemi Mosolasi

Amazing! thanks for sharing @Jahir

Collapse
 
burakuslu profile image
Burak Uslu

My Mac somehow decided to upgrade my Xcode to 11 while I am running OSX 10.14.1. I needed to download Xcode 10, except the developer.apple.com/Developer_Tools is keep dying on me. How does it upgrade from 10 to 11 but I can't download 10 back is beyond me.

Thank you with your suggestion. I am trying. It already failed half way once.

Collapse
 
raphaq profile image
RaphaQ

hello, very helpful post. may i ask, what if my mac shuts down how do i resume the download? thx

Collapse
 
jahirfiquitiva profile image
Jahir Fiquitiva

iirc running the same command again, from the same location, should continue the download

Collapse
 
wisdomfolutile profile image
Wisdom Deji-Folutile

please will this affect being able to automatically get updates? if so, how then can we update xcode when an update is available?

Collapse
 
jahirfiquitiva profile image
Jahir Fiquitiva

Hi ... unfortunately I didn't use Xcode long enough to give you a proper answer about that

Collapse
 
wisdomfolutile profile image
Wisdom Deji-Folutile

Okay, thanks for the speedy reply though. I’m grateful.

Collapse
 
ericgm profile image
Eric Githinji

Thanks Jahir! Quite helpful. Fell into the same issue trying to download xcode over a couple of days

Collapse
 
baronmax profile image
baronmax

Thanks Jahir - very useful

Collapse
 
karla profile image
Karla Pangilinan

Thank you! Been using this guide for more than a year now and it still works!

Collapse
 
jahirfiquitiva profile image
Jahir Fiquitiva

I'm glad it's been helpful and it's still working 😅 (sorry for the delayed response)

Collapse
 
sebastienkb profile image
Sébastien Kalb

This in combination with dev.to/szashik440/running-app-on-i... made me WAY less frustrated to work on Xcode during an updating period