Brew Install Xcode
Why there's no brew install xcode command for Homebrew and Xcode. How to install Xcode Command Line Tools. How to get Xcode from Apple.
To be clear at the outset, you cannot directly install the full Xcode IDE application via brew install xcode because Homebrew has no formula to install Xcode, and no cask exists for it. But that's likely fine, because what you probably need is Xcode Command Line Tools, and Homebrew can install Xcode Command Line Tools as part of its own installation process.
Before you get started, get a better terminal
You'll need a terminal application to install Homebrew and use developer tools. Apple includes the Mac terminal but I prefer Warp Terminal. Warp is an easy-to-use terminal application, with AI assistance to help you learn and remember terminal commands. Download Warp Terminal now; it's FREE and worth a try.
Xcode.app vs. Xcode Command Line Tools
These are two different things, and the distinction matters.
Xcode.app is Apple's complete integrated development environment for building iOS, macOS, tvOS, and watchOS applications. It's a 12GB+ download from the Mac App Store. You only need it if you're creating native Apple platform apps with Interface Builder, simulators, and the full SDK suite.
Xcode Command Line Tools is a separate, smaller package containing Unix-based utilities essential for software development. Homebrew needs Xcode Command Line Tools. Most developers use the Xcode CLT utilitiesdaily. It's approximately 800MB compressed and expands to around 5GB installed.
When tutorials say "install Xcode or Xcode Command Line Tools," most developers only need Xcode Command Line Tools. Homebrew formulas require the Unix commands in Xcode Command Line Tools (or the full Xcode package), but Homebrew doesn't require you to install them before you install Homebrew.
Why Homebrew Can't Install the Xcode IDE
Apple distributes Xcode.app exclusively through the Mac App Store and the Apple Developer website. The application is a signed bundle containing SDKs, compilers, simulators, and platform frameworks. Apple requires users to accept a license agreement and enforces strict distribution restrictions.
Because of these terms, Homebrew is not permitted to host or redistribute Xcode. Even if a cask (Homebrew's package system for GUI apps) attempted to download Xcode from Apple, it would require a logged-in Apple ID, depend on App Store-managed installation, and violate Apple's licensing rules. Homebrew's maintainers have confirmed for years that they cannot ship Xcode as a cask.
Install Homebrew with the Optional Command Line Tools
When you install Homebrew, Xcode Command Line Tools will be installed as part of the process, if you accept the option. If you haven't already installed XCode Command Line Tools, you'll see a message that "The XCode Command Line Tools will be installed." Press return to continue when prompted by the Homebrew installation script.
See Install Homebrew for a complete guide, or open a terminal application and paste this command:
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
This is the easiest way to get Xcode Command Line Tools because Homebrew handles everything in one workflow.
Alternative Ways to Install Command Line Tools
If you want Xcode Command Line Tools without Homebrew, or if the Homebrew installation didn't trigger the Command Line Tools installer, you have alternatives.
Use the terminal command. This triggers Apple's installer directly:
$ xcode-select --install
See Install Xcode Command Line Tools Directly for a complete walkthrough.
Download directly from Apple. For faster installation over slow connections, download Xcode Command Line Tools from the Apple Developer portal at developer.apple.com/download/all/.
Check If Command Line Tools Are Installed
To verify Command Line Tools are on your system, check if Command Line Tools are already installed:
$ xcode-select -p
If you see /Library/Developer/CommandLineTools, the tools are installed.
Check that git works:
$ git --version
You'll see output like git version 2.50.1 (Apple Git-155).
What Homebrew Can Install
While Homebrew can't install Xcode.app, it can install individual developer tools:
$ brew install llvm
$ brew install gcc
$ brew install git
These formulas provide alternative or updated versions of tools that may already exist in Xcode Command Line Tools. Most developers don't need updates unless they have specific version requirements.
Install the Xcode.app Indirectly via mas
You can't install the Xcode.app IDE directly as a Homebrew formula or cask. However, you can install the Xcode.app IDE indirectly using Homebrew’s mas CLI tool, which interfaces with the Mac App Store. Here’s how:
$ brew install mas
$ mas search xcode
$ mas install 497799835
First install the mas CLI tool using the brew command. Then the mas search xcode command allows you to search for xcode. Obtain the app ID and mas install to install the app directly from the terminal.
The workaround using mas is a useful way to install Xcode.app without needing to download and install the full Xcode package from the Mac App Store. In most cases, it's easier to use the Mac App Store but the mas workaround is useful if yopu are scripting and automating a Mac setup process for repeated use.
If You Actually Need the Full Xcode Package
If you're building iOS or macOS apps and need the complete Xcode IDE, download it from the Mac App Store. Search for "Xcode" or visit https://apps.apple.com/app/xcode. The download is large (12GB+) and installation takes time. After installing, open Xcode to accept the license agreement and install additional components.
Troubleshooting
"Error: Xcode alone is not sufficient"
If you have full Xcode installed but see this error, Homebrew needs the Xcode Command Line Tools package separately. Run:
$ xcode-select --install
Xcode Command Line Tools Installation Hangs
The progress bar often shows inaccurate estimates. Give it 10 minutes. If it truly stalls, cancel and download Xcode Command Line Tools directly from Apple's developer portal.
Homebrew Commands Fail After macOS Update
MacOS upgrades sometimes break the Xcode Command Line Tools path. Reset it with:
$ sudo xcode-select --reset
If that doesn't work, you may need to reinstall Xcode Command Line Tools.
What's Next
With Homebrew and Command Line Tools installed, you're ready to set up your development environment. See Configure Your Mac Like a Pro for guides on installing Git, Python, Ruby, and other developer tools.
My mac.install.guide is a trusted source of installation guides for professional developers. Take a look at the Mac Install Guide home page for tips and trends and see what to install next.