Summary

  1. Step 1. Upgrade Your System to macOS Sierra
  2. Step 2. Open the Terminal Application
  3. Step 3. Is XCode Already Installed?
  4. Step 4. Enter Commands
  5. Step 5. Install XCode Command Line Tools
  6. Step 6. Verify Installation

MacOS Sierra

To install the newest Xcode Command Line Tools, you’ll need the latest version of macOS. If you’ve owned your Mac for several years and haven’t updated macOS, be prepared to spend several hours updating the operating system.

See Apple’s instructions How to upgrade to macOS Sierra. You can install macOS 10.12 Sierra from the Mac App Store for free. Allow plenty of time for the download and installation (it may take several hours).

If You Updated to macOS Sierra

If you updated to macOS Sierra from an earlier version of macOS, and you previously installed Xcode Command Line Tools, you will need to install the new version of Xcode Command Line Tools as described here.

If you previously installed the full Xcode package, you will need to update Xcode to the newest version (Xcode 8 or newer). After updating Xcode, launch and run the Xcode application and accept the Apple license terms.

Terminal Application

The Terminal application or console gives us access to the Unix command line, or shell. We call the command line the shell because it is the outer layer of the operating system’s internal mechanisms (which we call the kernel).

Find the macOS Terminal application by using the Command-Spacebar combination and searching for “Terminal.” It’s in the Applications/Utilities/folder.

Try out the terminal application by entering a shell command:

$ whoami

Don’t type the $ character. The $ character is a cue that you should enter a shell command. This is a longtime convention that indicates you should enter a command in the terminal application. The Unix shell command whoami returns your username.

To learn more about Unix shell commands, read The Command Line Crash Course.

Is Xcode Already Installed?

You don’t need the full Xcode package to get the Xcode Command Line Tools. You only need the full Xcode package if you are doing development of applications for the Apple operating systems. However, you may have previously installed the full Xcode package.

Check if the full Xcode package is already installed:

$ xcode-select -p

If you see:

/Applications/Xcode.app/Contents/Developer

the full Xcode package is already installed.

You will need to update Xcode to the newest version (Xcode 8 or newer). Go to the App Store application and check “Updates.” After updating Xcode, be sure to launch the Xcode application and accept the Apple license terms.

If you intend to install Ruby using RVM, and you see a file location that contains spaces in the path:

/Applications/Apple Dev Tools/Xcode.app/Contents/Developer

you must delete Xcode. RVM cannot accommodate spaces in a path so RVM will fail when you attempt to install Ruby. You can either install only the Xcode Command Line Tools (instructions below) or reinstall the full Xcode package.

Install Xcode Command Line Tools

MacOS Sierra will alert you when you enter a command in the terminal that requires Xcode Command Line Tools. For example, you can enter gccor make.

Try it. Enter:

$ gcc

You’ll see an alert box:

Alternatively, you can use a command to install Xcode Command Line Tools. It will produce a similar alert box. Note the double hyphen:

$ xcode-select --install

Click “Install” to download and install Xcode Command Line Tools.

The instructions in the alert box are confusing. You don’t need to "Get Xcode" from the App Store. Just click "Install" for the Xcode Command Line Tools. If you have a slow Internet connection, it may take many minutes.

If the download takes a very long time (over an hour) or fails, you can try an alternative. Go to https://developer.apple.com/downloads/more and enter your Apple ID and password. You'll be asked to agree to the terms of the Apple Developer Program. You'll see a list of software packages you can download. Look for the latest version of Command Line Tools and click to download the .dmg file. Downloading the .dmg file is much faster than waiting for the command-line-based download. Install the .dmg file by clicking on the package icon.

Verify that you’ve successfully installed Xcode Command Line Tools:

$ xcode-select -p
/Library/Developer/CommandLineTools

Just to be certain, verify that gcc is installed:

$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

On earlier versions of macOS, it was more difficult to install Xcode Command Line Tools. It required a huge download of the full Xcode package from the Mac App Store or registration as an Apple developer for a smaller Command Line Tools package. Mac OS X Mavericks made installation of Xcode Command Line Tools much simpler.

Alternatives

The OSX GCC Installer is an open source project to provide the GCC compiler and related tools. In a recent blog post, Xcode, GCC, and Homebrew, the project maintainer recommends installing the Xcode Command Line Tools because the open source project is unable to duplicate the complete Apple package (notably, the Node software project isn’t supported).

Start Coding!

With the GCC compiler installed, you can install any Unix system tools you need for software development.

To install Rails, see the article Install Ruby on Rails – macOS.

Want to learn Ruby on Rails? See What is Ruby on Rails?, the book Learn Ruby on Rails, and recommendations for a Rails tutorial.

Xcode 8.X Command Line Tools的更多相关文章

  1. Mac appium.dmg. Xcode Command Line Tools

    You need to install the command line tools as marked in your message: ✖ Xcode Command Line Tools are ...

  2. appium----【已解决】【Mac】环境配置提示“Xcode Command Line Tools are NOT installed!"

    报错问题提示截图如下: 报错原因 :根据给出的信息很明显可以看到是"Xcode Command Line Tools"此工具没有安装 解决措施: 打开终端直接执行:xcode-se ...

  3. Xcode command line tools

    1.Xcode command line tools 安装 如果你不是一名 iOS 或 OS X 开发者,可以跳过安装 XCode 的过程,直接安装 Xcode command line tools. ...

  4. stderr: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

    错误提示: (1). stderr: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer direc ...

  5. 怎样安装Command Line Tools in OS x Mavericks&Yosemite(Without xcode)--转载

    How to Install Command Line Tools in OS X Mavericks & Yosemite (Without Xcode) Mac users who pre ...

  6. mac, xcode 6.1 安装command line tools 支持,autoconf,automake等

    以下软件包 都去我的环境库找到 1 先安装 tcl库 2 安装macports /opt/local/bin/port 一般装到这里 安装autoconf时提示: Warning: The Xcode ...

  7. could not launch process: debugserver or lldb-server not found: install XCode's command line tools or lldb-server

    0x00 事件 VS 调试 go 的时候,发生了这个错误,导致无法调试: could not launch process: debugserver or lldb-server not found: ...

  8. macOS Mojave 10.14 无法安装brew缺少Command Line Tools for Xcode的解决办法

    问题描述: 首先我的版本是 Xcode 10.1 如果按照以前的方法安装brew 复制 1 /usr/bin/ruby -e "$(curl -fsSL https://raw.github ...

  9. xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

    运行xcode命令报错: sh-3.2# xcodebuild xcode-select: error: tool 'xcodebuild' requires Xcode, but active de ...

随机推荐

  1. React-router4 第八篇 ReactCSSTransitionGroup 动画转换

    https://reacttraining.com/react-router/web/example/animated-transitions 动画转换这么高级,其实是又引入了一个组件,没什么特别, ...

  2. Javascript组成--ECMAScript,DOM,BOM

    ECMAScript 部分 ECMAScript是一个标准,JS只是它的一个实现,其他实现包括ActionScript; “ECMAScript可以为不同种类的宿主环境提供核心的脚本编程能力”,即EC ...

  3. java读取jar包中的文件

    随手写了一个java小工具,maven打包成功后,发现工具总是读不到打在jar包中的文件信息,要读取的文件位于 /src/main/resources 目录下,打包成功后,文件就在jar包中根目录下, ...

  4. Mybatis 中实体类的编写

    一个实体类对应一个数据表 一个属性对应一个字段 默认情况下类名和属性名都采用 “下划线转驼峰” 的命名方式.但具体采用什么样的命名方式并不重要(方式一致即可),在后面使用这些对象的时候,可以通过 re ...

  5. zeromq示例代码

    http://www.oschina.net/code/snippet_614253_55034 将zeromq代码使用vc集中到一个解决方案中 可编译可调调试 vc2015

  6. idea环境配置

    Idea 下载 https://www.jetbrains.com/idea/download/#section=windows idea安装(略) idea破解 window配置hosts文件:0. ...

  7. Asterisk 11 chan_sip.c: Failed to authenticate device 看不到IP的问题

    Asterisk 11 chan_sip.c: Failed to authenticate device 看不到IP的问题   没有验证过 原文地址 http://www.coochey.net/? ...

  8. Java中equals方法简略描述

    所有类都从Object中继承了equals方法,源码:public boolean equals(Object o){return this == o;} 直接判断this与o本身是否为同一对象(是否 ...

  9. sql 百万级或千万级数据分页处理

    笔记来源 https://blog.csdn.net/zhenyuanjie/article/details/7778102

  10. CSS Grid

    效果图如上所示 <!DOCTYPE html> <html> <head> <title>练习</title> </head> ...