The easiest way to install Xcode is using the Mac App Store.
But that’s not necessarily the best way.
While you can install Xcode with a simple click, using the Mac App Store is very slow, and the download might hang indefinitely or return cryptic errors.
The best alternative way to install Xcode is to download it from Apple’s website. If you are proficient enough, using the command line is the fastest.
In this article, we will look at all of the alternative ways to install Xcode, how to speed up the process, and how to resolve disk space problems. We’ll also look at the Windows alternative to Xcode.
Architecting SwiftUI apps with MVC and MVVMGET THE FREE BOOK NOW
Table of contents
- What is Xcode?
- Installing Xcode from the Mac App Store — Simple but slow
- Installing Xcode from Apple’s Website — Faster download (Recommended)
- Installing Xcode from the command line — Fastest but complicated
- What to do when you don’t have enough disk space to install Xcode (even if you think you do)
- Installing Xcode’s command line tools
- Running your Swift programs in Visual Studio Code on Windows or Linux
What is Xcode?
Xcode is an integrated development environment (IDE). In short, it’s an application with comprehensive functionality that helps developers write code and create apps.
While it’s an extensive and powerful application, you don’t need all of Xcode’s power as a beginner. You can find Xcode’s user guide here, but I recommend learning it step-by-step along with Swift and iOS development.
Xcode is free of charge, even though it’s a complex app that Apple keeps improving yearly. It has had its problems in the past, but it’s now becoming one of the best IDEs.
Xcode is not available on Windows
Xcode only runs on macOS. There is no Windows version. You can use Visual Studio Code as an alternative, but it’s limited to Swift.
Apple’s frameworks for app development, like SwiftUI, are not available on Windows. You need a Mac computer to develop and publish iOS apps. You can read about how to find cheap Mac and iOS devices here.
I recommend getting a Mac that can run the latest version of Xcode. You can find a table with the minimum OS required by all versions of Xcode on this page.
Installing Xcode from the Mac App Store — Simple but slow
The simplest way to install Xcode on your Mac is to download it from the Mac App Store.
The advantage of using the Mac App Store is how simple it is to install and update Xcode. After installation, Xcode will be located in your computer’s Applications folder together with all of your other apps.
Unfortunately, this is not the best way.
Downloading from the App Store can be extremely slow. Sometimes the download hangs, and you have no recourse other than canceling it and starting again.
The most common problem you will find is not having enough space on your disk to install Xcode, even when you think you do.
Most of the bad reviews on the App Store complain about this problem.
Installing Xcode from Apple’s Website — Faster download (Recommended)
A better alternative to the Mac App Store is downloading Xcode directly from Apple’s website. You can find the download button in the top-right corner of the Xcode page.
This is the method I recommend and the one I use myself. It’s faster than the Mac App Store and relatively simple.
On the download page, you will find several versions of Xcode, including the latest beta announced at Apple’s last World Wide Developer Conference (WWDC).
Which version of Xcode should you get?
- If you want to learn the latest features of Xcode, Swift, SwiftUI, and other Apple frameworks, download Xcode beta. Beware, though, that it can be buggy and crash often. You cannot use beta versions of Xcode to submit apps to the App Store.
- If you need to develop an app for the App Store, get the latest stable version of Xcode (which will be the version on the Mac App Store).
Your download will be a .xip archive file. Double-click on it to extract Xcode and then drag it into your Applications folder. And don’t forget to delete the archive once you have finished.
This can still be a long process, so keep reading if you know how to use the command line and want to save the most time.
Installing Xcode from the command line — Fastest but complicated
The fastest method to download and install Xcode is also the most complicated. It uses the aria2 command-line download utility that can open up to 16 connections. This makes the download much faster.
This method is only for experienced developers. It requires you to:
- use the command line;
- install the aria2 tool from its website or use Homebrew; and
- copy the download authorization cookie from Safari.
If you know how to do all of these things, you can find a step-by-step explanation here.
Decompress the Xcode XIP archive from the command line for faster performance
Once you have downloaded the Xcode .xip archive, you can decompress it using the command line:
xip -x Xcode_13.4.1
This is at least 25% faster than decompressing it in the finder and sometimes even twice as fast. If you want to know why, read this Twitter thread.
What to do when you don’t have enough disk space to install Xcode (even if you think you do)
People’s biggest complaint about Xcode is not having enough space on their disk to install it.
This happens because Xcode is a giant beast. Xcode 13.3 requires almost 33GB of disk space.
But that’s not all. Whether you download Xcode from the App Store or Apple’s website, you also have to factor in the archive file size.
The archive file for Xcode 13.4.1 takes up 10GB if you get it from Apple’s website and 12.6GB if you get it from the App Store. That’s the first reason why you might think you have enough space when you don’t. The other is related to APFS containers, which I’ll cover in more detail at the end of this section.
To know how much space you need, you have to add up the size of both files. So, you need at least 46GB of free disk space to install Xcode 13.4.1. And actually, you need even more than that because macOS needs some space for paging.
If you are like me, your disk is always almost full. So, let’s see how you can free up enough space to install Xcode.
- Download Xcode 14 beta if you can
- If you have never installed Xcode, delete large data or (temporarily) move it to an external drive
- Wipe out caches and other data that can be downloaded or generated again
- Freeing space when you have Xcode already installed
- What to do when you have enough free space, but you still get errors
If you already have Xcode installed, skip to the corresponding section to find out how you can free up disk space quickly.
Download Xcode 14 beta if you can
After years of complaints from developers, Apple finally listened.
One of the reasons why Xcode takes up so much space is that it contains the SDKs for iOS, macOS, tvOS, and watchOS.
But most developers don’t need all of these. Xcode 14 bundles the iOS and macOS SDKs and lets you only install the tvOS and watchOS SDKs if you want to.
Xcode 14, in beta at the time of writing, takes up just under 23GB, and its XIP archive takes up 7.5GB. So you only need 31GB of free space, which is 15GB less than what you need for Xcode 13.4.1.
If you have never installed Xcode, delete large data or (temporarily) move it to an external drive
If you have never installed Xcode, your options are limited, but it does not mean you can’t free up enough space for Xcode.
You will, however, need to delete some data or move it to an external drive. Since you only need most of the space to decompress Xcode, you can move the data back when you are done.
You can locate large files and folders using the System Information app. From the macOS menu, select About This Mac and go to the Storage tab. There, click on the Manage… button to open the app.
In the app’s sidebar, you will find various sections that suggest what data you can remove.
The Documents section is probably where you can make the most gains. It has Large Files and File Browser sections showing files and folders ordered by size.
Wipe out caches and other data that can be downloaded or generated again
The Applications section is an option that you should check. You can delete large apps and then download them again later from the App Store or the developer’s website. For example, Apple’s iMovie app takes up more than 2GB.
Apps on macOS save data outside their bundle, so you can delete any app safely without losing data.
The Library folder should also be a place that you consider. You can see its size using the Large Files tab in the Documents section of the System Information app.
One of the folders you can safely empty is Library/Caches. On my computer, that gave me back around 2GB.
However, the Library/Application Support folder is not a safe folder to delete because it contains the data of all your apps.
But, if it takes up a lot of space, it’s worth looking into it to see if any apps have saved too much data.
How you free up that space depends on the app. Google is your friend here.
One easy example is Safari, which has a Cache directory in the Containers folder. On my computer, this was taking up more than 2GB. I got this space back by clearing Safari’s cache (method #2).
Freeing space when you have Xcode already installed
If you already have Xcode installed and you need space to update it, you have more options.
First of all, delete the Xcode app. That alone might give you all the space you need.
You don’t have to worry about losing data. Like any other macOS app, Xcode saves data in different locations on your disk, so deleting the app is safe.
But you don’t have to stop there.
As you develop apps, Xcode also generates several artifacts that you can safely delete, like build data, indexes, caches, archives, and previews. All of these will stay on your disk even after you delete Xcode.
The easiest way to locate these artifacts is using the System Information app I discussed in the previous section. In the sidebar of the app, you will find a Developer section. How much space is taken up will depend on your individual case.
As you can see, I can reclaim more than 11GB from caches, build data, indexes, and iOS device support (I like to keep my Project Archives). That’s all data that Xcode can download or generate again.
What to do when you have enough free space, but you still get errors
Using all the methods listed above, I freed a whopping 55GB of space, which is enough to cover the 46GB I need to install Xcode.
In fact, the Storage tab of my About This Mac window shows that I have 73GB of free space.
However, you might still get errors even though it looks like you have more than enough space. You can check whether this is likely with the Disk Utility app, which says I only have 19.6GB free.
The reason for this is related to APFS containers. The solution is to create a large file and then delete it. You can find a lengthy explanation about this here.
Installing Xcode’s command line tools
After installing Xcode, you might also want to install Xcode’s command line tools.
This package enables UNIX-style development via Terminal by installing command line developer tools and macOS SDK frameworks and headers.
These tools are all already embedded in Xcode, so you might wonder why you need them.
There are two reasons:
- You get Git, a version control system indispensable for any serious development. And while Xcode has a pretty good Git integration, some commands and workflows are only available from the command line.
- If you need to set up a continuous integration server, you need these tools to maintain a central repository, automate build and deployment, and run tests.
You can get a .dmg package with Xcode’s command line tools in the same place where you can download Xcode.
If, instead, you want to install them from the command line, run this command:
You don’t need to install Xcode first for this command to work. It is available even on a fresh install of macOS.
Running your Swift programs in Visual Studio Code on Windows or Linux
Xcode and all the SDKs you need to develop apps for all Apple’s systems are available only on macOS. There is no Windows or Linux version.
That said, if you are just starting to learn Swift, you don’t need to delve into iOS development just yet. Instead, you can run Swift programs in Visual Studio Code, which you can download here.
Visual Studio Code is an IDE like Xcode. It’s open source and runs on Windows, Linux, macOS, and even on the web.
It’s not the most straightforward of processes, but it’s the only one I could find. That said, I’m not a Windows or Linux expert, so let me know if there is a better way.
There are several ways to install Xcode, but they are not the same.
My recommendation for the best mix of performance and ease of use is to download the XIP archive from Apple’s website and decompress it using the command line.
You can wait to install Xcode’s command line tools until you need them. However, I recommend learning to use Git as soon as possible. It will make your developer life much easier, even if you work alone on personal projects.
Architecting SwiftUI apps with MVC and MVVM
It’s easy to make an app by throwing some code together. But without best practices and robust architecture, you soon end up with unmanageable spaghetti code. In this guide I'll show you how to properly structure SwiftUI apps.
Matteo has been developing apps for iOS since 2008. He has been teaching iOS development best practices to hundreds of students since 2015 and he is the developer of Vulcan, a macOS app to generate SwiftUI code. Before that he was a freelance iOS developer for small and big clients, including TomTom, Squla, Siilo, and Layar. Matteo got a master’s degree in computer science and computational logic at the University of Turin. In his spare time he dances and teaches tango.