Wilson Mar bio photo

Wilson Mar

Hello. Hire me!

Email me Calendar Skype call 310 320-7878

LinkedIn Twitter Gitter Instagram Youtube

Github Stackoverflow Pinterest

The XCode IDE is a pre-requisite for Homebrew, Python, and other development tools

Español (Spanish)   Français (French)   Deutsch (German)   Italiano   Português   Cyrillic Russian   中文 (简体) Chinese (Simplified)   日本語 Japanese   한국어 Korean

Overview

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.

About XCode

PROTIP: Skip Apple’s websites and App. Click here for install instructions.

Otherwise, read on for a run-around.

  1. Use an internet browser to XCode’s marketing page at:

    https://developer.apple.com/xcode

    Xcode “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.


Two parts of XCode

There are two ways to different parts of XCode. Kinda of like a Venn diagram:

  1. The XCode IDE, which can be installed on a Terminal command line interface (CLI) or downloaded as a package from the App Store. Either way, XCode contain:
  2. Command Line Utilities which can be installed separately on a Terminal command line session.

XCode does not come with macOS.

Because XCode IDE takes so much disk space, developers who use another IDE (such as Visual Studio, Eclipse, etc.), prefer to only install XCode’s command line utilities for the GCC compiler Python needs to build code.

Newer versions also installs a Git client.

So it’s a good idea to identify what has been installed.

Version from XCode.app

If you don’t have XCode IDE installed, install it, then come back here.

  1. In Finder, look for XCode.app in the /Applications folder.

    Alternately, on the Touchpad pinch 4 fingers together to click the App Store. Type enough of “XCode” to filter out others.

  2. Double-click on the XCode.app to run it.

  3. To ciew the version, cursor to the top of the screen and click the program name next to the Apple icon to select “About XCode”:

    xcode about 271x48

Version of Command Utilities

  1. From within a Terminal, get the version installed :

    /usr/bin/xcodebuild -version
    

    A sample answer:

    Xcode 10.2.1
    Build version 10E1001
    

    The should match up with the Build Number on the Apple web page.

  2. For a more precise version number and other info (macOS Mavericks version and up):

    
    pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
    

    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
    
  3. Get the version of GCC installed:

    gcc --version

    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
    
  4. Identify the path where the make utility Java uses:

    xcrun --find gcc

    Sample response:

    /Applications/Xcode.app/Contents/Developer/usr/bin/make

  5. Get the version of the Swift program used to develop iOS mobile apps:

    swift -version

    Sample response:

    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 only

See http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x

The entire command line toolkit package gets placed in the following directory:

ls /Library/Developer/CommandLineTools/

The folders in there are: Library Packages SDKs usr


XCode IDE install from Terminal

PROTIP: Either way, if you have Command Utilities already installed, you must first delete it.

  1. In a Terminal window, find out where it’s installed:

    xcode-select -p
    

    After manual confirmation, the answer:

    /Applications/Xcode.app/Contents/Developer
    

    Alternately, combine two commands:

    
    ls $(/Applications/Xcode.app/Contents/Developer)
    

    Either way, the response is a list of folders:

    Applications Library      Makefiles    Platforms    Toolchains   Tools        usr

A) Initial install on Terminal CLI

  1. 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:

    /Applications/Xcode.app/Contents/Developer
    
  2. Set Apple’s licensing agreement bit:

    
    sudo xcodebuild -license
    
  3. Agree to the terms.

Read the XCode IDE’s ratings

  1. In an internet browser, get to the “Mac App Store Preview” at
    https://itunes.apple.com/us/app/xcode/id497799835

  2. Click View in Mac App Store, then “Open App Store.app” in the pop-up.
  3. 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.

  4. Scroll down to click See All on the right edge.
  5. Click “Sort by Most Recent”.
  6. Read through the Ratings to decide for yourself.
  7. Click the red dot at the upper-right to dismiss the dialog.

B) Initial IDE install using App Store

  1. In an internet browser, https://developer.apple.com/download

  2. Sign in to Apple Developer with your email address then click the arrow icon. Enter your password, then click the arrow icon.

    Below is the “Software Update” approach:

  3. You’ll need to establish an Apple ID if you haven’t already.

  4. Click Download and provide your Apple ID.

  5. Go through Apple’s location verification if prompted.

  6. Select the version to download:

    NOTE: Each version of XCode is related to a specific version of the Apple OS Mac operating system.

    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.

  7. Return to the versions instructions above to view the updated version.

  8. 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.

  1. Click the Apple icon, then click System Preferences. Here is an example notification:

    xcode-cli-update-436x98-4795

  2. Search for “Software Updates” or click the icon.
  3. Click “Update Now” if that appears. (but first do a backup.)
  4. Click “Agree” to the EULA.
  5. When done, view the version numbers installed.

More on OSX

This is one of a series on Mac OSX: