How to update Xcode from the command line

I am trying to update Xcode from the command line. First I tried to run:

xcode-select --install 

which led to this post:

 xcode-select: error: command line tools are already installed, use "Software Update" to install updates 

So the question remains, is there a way to update Xcode from the command line?

+195
xcode
Jan 05 '16 at 17:14
source share
10 answers

You actually use the command to install the Xcode command line tools - xcode-select --install . Hence the error message: the tools are already installed.

The command you need to update Xcode is softwareupdate command [args ...] . You can use softwareupdate --list to see what is available, and then softwareupdate --install -a to install all the updates, or softwareupdate --install <product name> to install only the softwareupdate --install <product name> update (if available). You can get the name from the list command.

As mentioned in the comments here, this is a man page for the softwareupdate tool.

2019 update

Many users run into problems when softwareupdate --install -a does not actually softwareupdate --install -a to the latest version of Xcode . The reason for this is most likely the upcoming macOS update (as @brianlmerritt below). In most cases, updating macOS will be the first to solve the problem and also allow you to update Xcode .

Xcode Command Line Tools Update

Most users use this answer when trying to update the Xcode command line tools . The easiest way to achieve this is to uninstall the old version of the tools and install a new one.

 sudo rm -rf /Library/Developer/CommandLineTools xcode-select --install 

A pop-up window will appear that guides you through the rest of the process.

+196
Jan 05 '16 at 17:38
source share

I had the same problem and I solved by doing the following:

  • removal of old tools ( $ rm -rf /Library/Developer/CommandLineTools )
  • reinstall the xcode command line tools ( $ xcode-select --install ).

After these steps you will see pop to install a new version of these tools.

+135
Dec 14 '17 at 0:16
source share

I encountered the same problem when I uninstalled the full version of Xcode in order to reinstall the CLI version. My fix was:

sudo xcode-select -s/Library/Developer/CommandLineTools

+31
Jan 07 '18 at 4:57
source share

It saved my day. Just enter commands

 cd /Library/Developer/CommandLineTools/Packages/; open macOS_SDK_headers_for_macOS_10.14.pkg 

Link: https://forums.developer.apple.com/thread/104296

+14
Apr 17 '19 at 16:37
source share

I got this error after uninstalling Xcode. I fixed it by resetting the command line tool path using sudo xcode-select -r .

Before:

 navin@Radiant ~$ /usr/bin/clang xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools. See `man xcode-select` for more details. navin@Radiant ~$ xcode-select --install xcode-select: error: command line tools are already installed, use "Software Update" to install updates 

After:

 navin@Radiant ~$ /usr/bin/clang clang: error: no input files 
+13
Nov 15 '17 at 20:12
source share

@Vel Genov's answer is correct, unless the Xcode version cannot be updated because it is the latest version for your current version of Mac OS. If you know that there is a newer Xcode (for example, it will not download the application to a device with the latest version of iOS), then you must first update Mac OS.

Note for anyone like me with the old Mac Pro 5.1. Upgrading to Mojave required the installation of a metal graphics processor (in my case, Sapphire AMD Radeon RX 560), but make sure that only an HDMI monitor is installed (not just 4K! 1080). Only after that Mojave installed a firmware update and turned off the computer. Long hold the 2-minute power button and all this was perfectly updated after that!

+8
Sep 24 '17 at 8:10
source share

I tried to use the React-Native Expo app with the create-Reaction-native-app, but for some reason it ran my simulator and just crashed without loading the app. The above answer from ipinak above resets the Xcode command line interface tools because trying to upgrade to the latest version of the Xcode command line interface does not work. two teams:

 rm -rf /Library/Developer/CommandLineTools xcode-select --install 

This process takes time due to loading. I leave this here for any other searches for this specific React-Native Expo fix.

+5
Oct. 16 '18 at 7:53
source share

Xcode :: Install is a simple software that allows you to install / select a specific version of Xcode.

You can install it using gem install xcode-install
Then you can install the specific version with xcversion install 9.4.1
And if you have more than one version installed, you can switch the version with xcversion select 9.4

You can find more information at https://github.com/KrauseFx/xcode-install

+3
Aug 16 '18 at 6:34
source share

After installing the command line tools (using xcode-select --install ), enter:

 sudo xcode-select --switch /Library/Developer/CommandLineTools/ 

Now you should run git:

 10:29 $ git --version git version 2.17.2 (Apple Git-113) 
+3
Feb 01 '19 at 12:35
source share
 $ sudo rm -rf /Library/Developer/CommandLineTools $ xcode-select --install 
+3
Aug 22 '19 at 4:21
source share



All Articles