How to Trigger Xcode's 'Update to Latest Package Versions' from Command Line

How to update Xcode from command line

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.

How to update swift package imported to Xcode Project via Swift Package Manager?

Option 1: (Xcode 13 and above)

Right-click on the package from the left navigation pan and select Update Package

Xcode 13

Option 2:

Double click on the package in the tab you mentioned and change the version to anything else. It will then recheck the remote repo. The benefit of doing this is to only update the selected package. (Also, it's better to have the current using version be set in the package.)

Option 3:

From File -> Swift Packages -> Update to Latest Package Versions

SS

How to update Xcode Command Line Tools?

For future travelers, here's a version-agnostic approach. First, run softwareupdate --list. This will probably take a couple of minutes. When it's done, you'll see a bulleted (with an asterisk) output like this:

$ softwareupdate --list
Software Update Tool

Finding available software
Software Update found the following new or updated software:
* Command Line Tools (macOS High Sierra version 10.13) for Xcode-10.1
Command Line Tools (macOS High Sierra version 10.13) for Xcode (10.1), 190584K [recommended]

Find the bullet that refers to the Xcode command line tools. Copy that entire line (except the asterisk...). In the above case, you would copy: Command Line Tools (macOS High Sierra version 10.13) for Xcode-10.1

Then, run the install command (as shown by Brendan Shanks) with what you copied inside quotes:

softwareupdate -i "Command Line Tools (macOS High Sierra version 10.13) for Xcode-10.1"

How do you update Xcode command line tool on OSX to the latest version?

"Note: In OS X 10.9, Software update notifies you when new versions of the command-line tools are available for update."

https://developer.apple.com/library/ios/technotes/tn2339/_index.html

I found this note, so it seems not updated or installed from command line, separately from xcode itself, even though it WAS on the list of app store update.



Related Topics



Leave a reply



Submit