Skip to content

Instantly share code, notes, and snippets.

@brianjbayer
Created November 19, 2023 06:05
Show Gist options
  • Save brianjbayer/0b44c2b9baddd62a85922b971870b132 to your computer and use it in GitHub Desktop.
Save brianjbayer/0b44c2b9baddd62a85922b971870b132 to your computer and use it in GitHub Desktop.
How to install Apple Xcode and the Homebrew package manager

Install Xcode

You will need to install the Apple Xcode developer tools application from the App Store.

🔒 You will need an Apple ID to sign into the App Store to download XCode

⏩ Try clicking this link in Safari and following any prompts to allow opening the App Store https://apps.apple.com/us/app/xcode/id497799835 it might take you right to Xcode in the App Store or...

  1. Open the App Store application

  2. Use the App Store's search box to search for xcode which should return the Xcode Developer Tools application

  3. Follow the App Store download and installation process to install Xcode - You will must likely be prompted at some point to log in with your Apple ID if you are not already logged in.

⏳ It may take awhile for Xcode to download and install


Install Homebrew

🍺 Homebrew is a package manager for Mac. You use it to make it easier to install and manage your programs and utilities needed for development and some applications such as Chrome, Docker, VS Code etc.

✨ The Homebrew install script will start by installing (XCode) Command Line Tools which includes the gcc compiler

  1. Go to https://brew.sh/ and follow the installation instructions for Mac or you can try the following command (which came from the site at the time of this post)

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  2. READ the output of the installation and follow any instructions

    To install Command Line Tools, you will probably need to complete the installation in...

    System Settings > General > Software Update

Depending on the Mac architecture, Homebrew is installed...

FOR... INSTALLED AT...
Apple Silicon /opt/homebrew
macOS Intel /usr/local

The Homebrew install script output should tell you what lines to add to your ~/.zshrc (~/.zprofile) file.

At the time of this post for Apple Silicon-based macOS Sonoma, the instructions directs you to (edit and) add the following lines to your ~/.zshrc (~/.zprofile) file

eval "$(/opt/homebrew/bin/brew shellenv)"

I peeked into the homebrew script source and have this in my basic mac-dev-zsh-profile repository which works for either architecture...

# Add brew shellenv to your ~/.zshrc file"
# This is inside baseball from the brew install script
# Determine where brew itself is installed based on Intel vs Apple Silicon
[[ `uname -m` == "arm64" ]] && homebrew_prefix="/opt/homebrew" || homebrew_prefix="/usr/local"
eval "$(${homebrew_prefix}/bin/brew shellenv)"
unset homebrew_prefix

After installing Homebrew, you can now start installing your system libraries, tools, and programs and have them managed by Homebrew.

Verify That gcc Is Installed

To verify that Command Line Tools and the gcc compiler is successfully installed...

gcc --version

You should see output something like this...

Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: arm64-apple-darwin23.1.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Installing Homebrew Activates git

Once Homebrew is installed, you will have git available.

There will not be any configuration or credentials but you do have https access to public repositories. You can keep basic configuration and setup scripts to automate your setup from here.


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