How to install Xcode Command Line Tools

后端 未结 13 1949
無奈伤痛
無奈伤痛 2020-11-22 01:08

How do I get the command-line build tools installed with the current Xcode/Mac OS X v10.8 (Mountain Lion) or later?

Unlike Xcode there is no installer, it\'s just a

13条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 01:32

    I recently had to install Xcode command line tools on Mountain Lion over SSH.

    Notice: I imagine this process would work identically for any version of Xcode or OSX. Just make sure you get your paths correct.

    Here's how I did it...

    1. If you don't have a free Apple developer account, register for one

    2. Login to https://developer.apple.com/downloads

    3. Download the "Command Line Tools for Xcode" appropriate for your version of OSX

      For me, that was "Command Line Tools (OS X Mountain Lion) for Xcode - April 2014"

    4. Copy the dmg file to your remote

      In the following command, I'm using scp to securely copy the file from my local computer to the remote named remote

      $ scp ~/Downloads/command_line_tools_for_osx_mountain_lion_april_2014.dmg remote:Downloads/
      
    5. ssh to your remote

      $ ssh remote
      
    6. mount the dmg file on the remote

      Here, I'm using hdiutil to mount the image

      $ hdiutil attach ~/Downloads/command_line_tools_for_osx_mountain_lion_april_2014.dmg
      
    7. install the package contained in the dmg

      Here, installer must be run with sudo because this package needs to be installed on the root file system

      $ cd /Volumes/Command\ Line\ Tools\ \(Mountain\ Lion\)
      $ sudo installer -pkg Command\ Line\ Tools\ \(Mountain\ Lion\).mpkg -target /
      
    8. unmount the dmg file

      $ hdiutil detach /Volumes/Command\ Line\ Tools\ \(Mountain\ Lion\)
      
    9. delete the dmg file from the remote; optional

      I see no purpose keeping it around, but you can if you want.

      $ rm ~/Downloads/command_line_tools_for_osx_mountain_lion_april_2014.dmg
      

提交回复
热议问题