Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update Xcode from command line

Tags:

xcode

I am trying to update Xcode from the command line. Initially I tried running:

 xcode-select --install 

which resulted in this message:

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?

like image 250
psvj Avatar asked Jan 05 '16 17:01

psvj


People also ask

How do I update Xcode on Mac?

Downloading and updating XcodeThe current release of Xcode is available as a free download from the Mac App Store. The Mac App Store will notify you when an update is available or you can have macOS update automatically as it becomes available.

How do I update Xcode on Mac without App Store?

The normal way you upgrade Xcode via direct download is to download the new version, extract it from the XIP, and drag it into Applications. Are you having a problem with that? There is no patch-in-place; you just download the new version.


1 Answers

What you are actually using is the command to install the Xcode command line tools - xcode-select --install. Hence the error message you got - the tools are already installed.

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

As it was mentioned in the comments here is the man page for the softwareupdate tool.

2019 Update

A lot of users are experiencing problems where softwareupdate --install -a will in fact not update to the newest version of Xcode. The cause for this is more than likely a pending macOS update (as @brianlmerritt pointed out below). In most cases updating macOS first will solve the problem and allow Xcode to be updated as well.

Updating the Xcode Command Line Tools

A large portion of users are landing on this answer in an attempt to update the Xcode Command Line Tools. The easiest way to achieve this is by removing the old version of the tools, and installing the new one.

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

A popup will appear and guide you through the rest of the process.

like image 110
Vel Genov Avatar answered Sep 18 '22 09:09

Vel Genov