Archive
Finding the version number of the Xcode command line tools using the softwareupdate command
As part of making sure your development environment is up to date, it’s often helpful to know what version of Xcode or the Xcode Command Line Tools that you’re using. For Xcode, this is relatively straightforward as you can check Xcode.app‘s version number or you can use the command shown below:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xcodebuild -version |
On a Mac running Xcode, running that command should provide output similar to what’s shown below:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
username@computername ~ % xcodebuild -version | |
Xcode 14.2 | |
Build version 14C18 | |
username@computername ~ % |
However, for the Xcode Command Line Tools, this process isn’t as straightforward. There isn’t a specific app to check for version information and running the command above results in the following output:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
username@computername ~ % xcodebuild -version | |
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance | |
username@computername ~ % |
So how can you determine the latest installed version of the Xcode Command Line Tools? One way is to use the softwareupdate command’s history function, which should show all of the versions of the Xcode Command Line Tools which have been installed. You can use the following command to display all the installations of the Xcode Command Line Tools:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
softwareupdate –history | grep "Command Line Tools for Xcode" |
For example, since both Xcode Command Line Tools 12 and Xcode Command Line Tools 13 are available for macOS Big Sur 11.7.x, you may see output similar to what’s shown below on a Mac running Big Sur:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
username@computername ~ % softwareupdate –history | grep "Command Line Tools for Xcode" | |
Command Line Tools for Xcode 12.5 09/21/2022, 15:04:54 | |
Command Line Tools for Xcode 13.2 01/17/2023, 11:18:19 | |
username@computername ~ % |
Since the latest installed version of the Xcode Command Line Tools should be listed at the bottom of the output from the softwareupdate command’s history function, you should be able to use the following command to get the version number of the latest installed version of the Xcode Command Line Tools:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
softwareupdate –history | awk '/Command Line Tools for Xcode/ {print $6}' | tail -1 |
As of the date of this post, the latest version of the Xcode Command Line Tools on macOS Ventura 13.1 is version 14.2, so you should see output similar to what’s shown below on a fully updated macOS 13.1 Mac running the latest version of the Xcode command line tools:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
username@computername ~ % softwareupdate –history | awk '/Command Line Tools for Xcode/ {print $6}' | tail -1 | |
14.2 | |
username@computername ~ % |
Notarizing Automator applications
Apple recently updated their notarization documentation to include this note:
Beginning in macOS 10.14.5, all new or updated kernel extensions and all software from developers new to distributing with Developer ID must be notarized in order to run. In a future version of macOS, notarization will be required by default for all software.
The part about “notarization will be required by default for all software” made me think, because there are a few apps that I’ve written over the years that are still useful (at least to me). All of them were built using Automator, which meant that the usual Xcode-based ways of notarizing applications wasn’t going to work for me.
With assistance by folks in the MacAdmins Slack though, I was able to develop a process that allowed me to do the following:
- Codesign an Automator application
- Upload the application to Apple for notarization
- Attach the notarization to the application
- Verify that the notarization was attached and valid.
The documentation linked below was also very helpful in figuring out how to notarize using command line tools:
- https://developer.apple.com/documentation/security/notarizing_your_app_before_distribution/customizing_the_notarization_workflow
- https://developer.apple.com/documentation/security/notarizing_your_app_before_distribution
For more details, please see below the jump.
Updated Xcode command line tools installer script now available
A while back, I developed a script that will download and install the Xcode Command Line Tools on Macs running 10.7.x and higher.
Most of the time it works fine. However, starting with macOS Sierra and continuing on with macOS High Sierra, I occasionally ran into an odd problem. Apple would sometimes have both the latest available Xcode Command Line Tools installer and the just-previous version available on Apple’s Software Update feed.
The original script was written with the assumption that there would only be one qualifying Xcode Command Line Tools install option available at any one time. When more than one is available, the script isn’t able to correctly identify which Xcode Command Line Tools it should be installing. The result is that the script ends without installing anything.
Apple usually removes the previous version from the Software Update feed within a few days, which allows the script to work normally again. But when it happened this time, I decided to update the script to hopefully fix this issue once and for all. For more details, please see below the jump.
Installing the Xcode command line tools on 10.7.x and later
A number of Mac admins need to provide the Xcode Command Line Tools for the Macs in their environments, either as part of building machines or afterwards. To help with this task, I’ve developed a script that will download and install the Xcode Command Line Tools on Macs running 10.7.x and higher. See below the jump for more details.
Building a Grand Unified Xcode 5.0.2 installer for Mavericks and Mountain Lion
Apple has released Xcode 5.0.2 through the Mac App Store for all Macs running 10.8.4 and higher. While the command line tools for Mavericks are now included with Xcode, the command line tools for Mountain Lion can be installed separately through the Xcode preferences, in the Downloads section.
For my users who are developers, Xcode is part of their their new machine builds. I wanted to include Xcode 5.0.2 and also, where appropriate, install the command line tools automatically without needing to enter an Apple ID. With a little help from the Mac App Store, I was able to do this using Packages. See below the jump for the details.
Xcode Command Line Tools included with Xcode 5.0.x on Mavericks
Something I’ve always tried to include with Xcode installations are the Xcode command line tools. Starting in Xcode 4.3, Apple stopped bundling these tools by default and instead made them an optional install.
Since having these tools is useful, I re-packaged various versions of Xcode so that I could include these tools as part of the install. One of the ways I could tell that they were installed was by going into Xcode’s Downloads preferences panel and see if the Command Line Tools showed up with a checkbox entry.
Starting in Mavericks though, the Command Line Tools entry disappeared from Downloads.
Meanwhile, the Xcode command line tools themselves moved. In Mountain Lion, the Xcode 5.0.x command line tools are installed into /usr/bin and other system software directories.
In Mavericks, they are installed into /Library/Developer.
Why was this happening? After some digging and some collaborative work in the ##osx-server IRC room, an answer was found. See below the jump for details.
Building a Grand Unified Xcode 5.0.1 installer for Mavericks and Mountain Lion
Apple has released Xcode 5.0.1 through the Mac App Store for all Macs running 10.8.4 and higher. The command line tools can be installed separately through the Xcode preferences, in the Downloads section.
For my users who are developers, I wanted to include Xcode 5.0.1 in their new machine builds and also install the command line tools automatically without needing to enter an Apple ID. I also wanted to build this installer as a flat package, so I’m shifting from my previous method using Iceberg to using Packages to build the installer package. With a little help from the Mac App Store, I was able to do this. See below the jump for the details.
Building a Grand Unified Xcode 5.0 installer for Mountain Lion
Apple has released Xcode 5.0 through the Mac App Store for all Macs running 10.8.4 and higher. The command line tools can be installed separately through the Xcode preferences, in the Downloads section. You now need an Apple Developer Connection account to install the Xcode 5 command line tools via the Xcode preferences, though a free ADC membership is sufficient.
For my users who are developers, I wanted to include Xcode 5.0 in their new machine builds and also install the command line tools automatically without needing to enter an Apple ID. I also wanted to build this installer as a flat package, so I’m shifting from my previous method using Iceberg to using Packages to build the installer package. See below the jump for the details.
Building a Grand Unified Xcode 4.4 installer for both Lion and Mountain Lion
Apple has released Xcode 4.4 through the Mac App Store for all Macs running 10.7.4 and higher, including Mountain Lion. This application, on first launch, then installs the other Xcode tools. The command line tools can be installed separately through the Xcode preferences, in the Downloads section.
For my users who are developers, I wanted to include Xcode 4.4 in their new machine builds and also install the command line tools automatically. I also wanted to build one Xcode 4.4 installer that worked for both 10.7.x and 10.8.x. The Xcode 4.4 application itself runs fine on both Lion and Mountain Lion, but the command line tools are OS-specific.
To do this, I used a modified form of the methodology referenced in this post to repackage Xcode 4.4 for distribution without needing an Apple ID. See below the jump for the procedure.
Changing Keychain Minder’s displayed text using Xcode
I was recently asked about my organization’s Keychain Minder application, as I had altered the displayed text to better meet my organization’s needs.
For those who also want to do this for their own organization, see below the jump for the procedure I’ve used.
Recent Comments