by Daniel Kehoe

Last updated 28 December 2013

How to install Apple Xcode Command Line Tools for Mac OS X 10.9 Mavericks.

Xcode is a large suite of software development tools and libraries from Apple. The Xcode Command Line Tools are part of XCode. Installation of many common Unix-based tools requires the GCC compiler.
The Xcode Command Line Tools include a GCC compiler. This article shows how to install Xcode Command Line Tools to use the GCC compiler and more.

Installing Ruby on Rails

If you are setting up your computer for developing web applications with Ruby on Rails, see this article for complete instructions:

Install Ruby on Rails – Mac OS X Mavericks

If You Are New to Rails

If you’re new to Rails, see What is Ruby on Rails?, the book Learn
Ruby on Rails
, and recommendations for a Rails tutorial.

What is the RailsApps Project?

This is an article from the RailsApps project. The RailsApps project provides example applications that developers use as starter
apps. Hundreds of developers use the apps, report problems as they arise, and propose solutions. Rails changes frequently; each application is known to work and serves as your personal “reference implementation.” Each application is accompanied by a tutorial
so there is no mystery code. Support for the project comes from subscribers. Please accept our invitation to join the RailsApps project.

Mac OS X Mavericks

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

See Apple’s instructions How to upgrade to OS X Mavericks. You can install Mac OS X 10.9 (Mavericks) 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 Mac OS X Mavericks

If you updated to Mavericks from an earlier version of Mac OS X, 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 5.01 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 Mac OS X Terminal application by using the Command-Spacebar combination and searching for “Terminal.” It’s in theApplications/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 5.01 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

Mac OS X Mavericks will alert you when you enter a command in the terminal that requires Xcode Command Line Tools. For example, you can enter gcc or make.

Try it. Enter:

$ gcc

You’ll see an alert box:

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.

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 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix

On earlier versions of Mac OS X, 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 makes 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 – Mac OS X.

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

Credits

Daniel Kehoe wrote the article.

转载自:http://railsapps.github.io/xcode-command-line-tools.html

最新文章

  1. 批发零售车销门店扫描打印一体移动销售POS机-移动终端销售O2O新模式
  2. 架构实例之Demo_JSP_JavaBean_Servlet
  3. xcode 消除警告
  4. mysql数据库的安装与使用
  5. 关于leetcode中链表中两数据相加的程序说明
  6. 为sql server 增加 parseJSON 和 ToJSON 函数
  7. TCP连接状态与2MSL等待时间
  8. python3使用requests登录人人影视网站
  9. IOS 类别与扩展的区别 (category & extensions)
  10. Jquery 控件
  11. ActionBar官方教程(8)ShareActionProvider与自定义操作项提供器
  12. 我的第一个MVC项目
  13. HTML基础知识(未完待续)
  14. ico图标在谷歌浏览器中如何显示?
  15. JavaEE EL & JSTL 学习笔记
  16. linux 软连接创建 压缩解压缩 linux的dns服务相关
  17. CentOS6.x网易163yum源配置
  18. Mac OSX配置XAMP虚拟主机
  19. <context annotation-config />标签意义
  20. (字典树)How many--hdu--2609

热门文章

  1. redis-持久化、主从复制、集群
  2. jdbc 事物 commit 和rollback方法
  3. Service系统服务(四):搭建单区域DNS服务器、特殊DNS解析、配置DNS子域授权、搭建并测试缓存DNS
  4. WebRequest发送请求并接收返回值
  5. css使子元素在父元素居中的各种方法
  6. 测试技能图谱skill-map
  7. C++ placement new与内存池
  8. 引用so动态链接库的方法
  9. 微服务-技术专区-链路追踪(pinpoint)-部署使用
  10. tar 和gzip 的区别