This is a pre-requisite for Homebrew, Python, and other development tools
This tutorial describes the installation and usage of Apple’s XCode set of utilities for macOS developers.
XCode is Apple’s free app for developing custom programs for all Apple devices (macOS, iPhone, iPad, Apple Watch).
Since the Apple Store only handles individual .app files, other mechanisms are needed to install additional programs needed as a pre-requisite by Homebrew, Python, and other development programs.
XCode does not come with macOS.
PROTIP: Skip Apple’s websites and App. Click here for install instructions.
Otherwise, read on for a run-around.
Use an internet browser to XCode’s marketing page at:
“Xcode 10 includes everything you need to create amazing apps for all Apple platforms. Now Xcode and Instruments look great in the new Dark Mode on macOS Mojave. The source code editor lets you transform or refactor code more easily, see source control changes alongside the related line, and quickly get details on upstream code differences. You can build your own instrument with custom visualization and data analysis. Swift compiles software more quickly, helps you deliver faster apps, and generates even smaller binaries. Test suites complete many times faster, working with a team is simpler and more secure, and much more.”.
BTW the “Apple platforms” include MacOS, iPhone, iPad, Apple TV, and Apple Watch.
Click the blue “Download” at the top of the page to see the lastest version
Click that blue “Download” button to get to the “Mac App Store Preview</a> at https://itunes.apple.com/us/app/xcode/id497799835
- Click View in Mac App Store, then “Open App Store.app” in the pop-up.
Provide your Apple ID and password. Get one if you don’t already have one.
Don’t click the blue “OPEN” icon at the upper-right to open the app if the app was installed.
- Scroll down to click See All.
- Click “Sort by Most Recent”.
- Read through the Ratings to decide for yourself.
Two XCode installs - different scope
Because XCode IDE takes so much disk space, developers who use another IDE (such as Visual Studio), prefer to only install XCode’s command line utilities for the GCC compiler Python needs. Newer versions also installs a Git client.
So it’s a good idea to identify what has been installed.
If you don’t already have XCode installed, click here for install instructions.
NOTE: Each version of XCode is related to a specific version of the Apple OS Mac operating system.
Know the version by clicking on the program name next to the Apple icon, then select “About XCode”:
Alternately, get the version installed from within a Terminal:
A sample answer:
Xcode 10.2.1 Build version 10E1001
The should match up with the Build Number on the Apple web page.
Alternately, for a more precise version number and other info (Mavericks and up):
A sample response:
package-id: com.apple.pkg.CLTools_Executables version: 10.2.0.0.1.1552586384 volume: / location: / install-time: 1554972853 groups: com.apple.FindSystemFiles.pkg-group
The previous command is a specific version of:
pkgutil --pkgs | grep -i tools
Get the version of GCC installed:
A sample answer:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1 Apple LLVM version 10.0.1 (clang-1001.0.46.4) Target: x86_64-apple-darwin18.5.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Identify the path where the make utility Java uses:
xcrun --find gcc
Get the version of the Switch used to develop iOS mobile apps:
Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5) Target: x86_64-apple-darwin18.5.0
Install Command Line Utilities
The entire command line toolkit package gets placed in the following directory:
The folders in there are: Library Packages SDKs usr
XCode IDE install
XCode IDE can be installed from a Terminal command line interface (CLI) or as a package from the App Store.
Either way, if you have command utilities installed, you must first delete it.
In a Terminal window, find out where it’s installed:
After manual confirmation, the answer:
Alternately, combine two commands:
Either way, the response:
Applications Library Makefiles Platforms Toolchains Tools usr
A) Initial install on Terminal CLI
Open a Terminal.app console window at any directory to install the latest XCode from Apple:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
This large installer can take hours to download.
If the XCode IDE is already installed, you’ll see message:
xcode-select: error: command line tools are already installed, use “Software Update” to install updates
Another error message:
xcode-select: error: tool ‘xcodebuild’ requires Xcode, but active developer directory ‘/Library/Developer/CommandLineTools’ is a command line tools instance
Otherwise, after manual confirmation, the answer:
Set Apple’s licensing agreement bit:
sudo xcodebuild -license
Agree to the terms.
B) Initial install using App Store
On MacOS the XCode IDE is downloaded from the Apple Store app and stored in the “/Applications” folder as file XCode.app.
On the Touchpad pinch 4 fingers together to click the App Store. Search for “XCode”.
If the blue “Open” button appears, then XCode.app has already been installed.
Click “Install” if that appears.
The Apple Store app is stored in the “/Applications” folder as “XCode.app”.
So below is the “Software Update” approach:
Click Download and provide your Apple ID. You’ll need to establish an Apple ID.
Go through Apple’s location verification if prompted.
Select the version to download:
File Date Download Unpacked XCode_10.2.1 2019-04-17 ? GB 6.1 GB XCode_9.0 2017-09-19 . ? GB ? GB XCode_8.2.1 8C1002 2016-12-19 ? GB ? GB XCode_8_beta_2.xip 2016-07-05 5.9 GB 12.32 GB XCode_7.31 2016-05-03 3.8 GB ? XCode_4.1 2014- 2.9 GB ? XCode_3.2.4 2014- 2.? GB ?
CAUTION: Make sure that your machine has enough free space available.
These are massive files that may take a while to download if you don’t have a fast internet connection.
Return to the versions instructions above to view the updated version.
Remember to delete the installer after you’re done, to reclaim disk space.
XCode IDE Upgrade
Over time, Apple updates XCode and its command line utilities.
Click the Apple icon, then click System Preferences. Here is an example notification:
- Search for “Software Updates” or click the icon.
- Click “Update Now” if that appears. (but first do a backup.)
- Click “Agree”.
- When done, view the version numbers installed.
More on OSX
This is one of a series on Mac OSX:
- MacOS Hardware and accessories
- MacOS Boot-up
- MacOS Terminal Tips and Tricks
- MacOS Keyboard tricks
- Text editors and IDEs on MacOS
- MacOS Setup automation
- MacOS Homebrew installers
- Manage Disk Space on MacOS
- Data Backups on MacOS
- Ports open
- Applications on MacOS
- Windows on Apple MacOS
- Packer create Vagrant Windows image
- Python on MacOS
- Maven on MacOS
- Ruby on MacOS
- Java on MacOS
- Node on MacOS installation
- PHP on MacOS
- Scala ecosystem