Programmatically determine version of Xcode installed

Prior to Ventura betas, I was able to determine the version of Xcode and CLT with the following script:

# https://apple.stackexchange.com/questions/180957/determine-xcode-command-line-tools-version
# This worked on Big Sur (ARM) 11.1 beta
# Xcode
if pkgutil --pkgs=com.apple.pkg.Xcode >/dev/null; then
    echo Xcode: $(pkgutil --pkg-info=com.apple.pkg.Xcode | awk '/version:/ {print $2}')
else
    echo Xcode: not installed
fi

# Command Line Tools for Xcode
if pkgutil --pkgs=com.apple.pkg.CLTools_Executables >/dev/null; then
    echo CommandLineTools: $(pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | awk '/version:/ {print $2}')
else
    echo CommandLineTools: not installed
fi

Working with the Ventura 13.0 beta (22A5321d), I have Xcode 14.0 beta 5 (14A5294e) installed as well as CLT 14.0.0.0.1.1658620134. The output of the above script tells me that Xcode is not installed. Xcode was installed from the developer downloads (not the App Store).

Xcode: not installed
CommandLineTools: 14.0.0.0.1.1658620134

Has something changed with the pkgutil utility or the way Xcode reports itself to pkgutil?

Programmatically determine version of Xcode installed
 
 
Q