Install Xcode 12.5 from the command line

Hello,

I am installing Xcode on a headless system (terminal only). My script to install Xcode 12 is not working anymore with Xcode 12.5.

Assuming that I have downloaded already Xcode.xip and the Command Line Tools package from Apple's web site :

   xip --expand xcode.xip 
   sudo mv Xcode.app /Applications

   hdiutil mount ./xcode-cli.dmg 
   sudo installer -pkg /Volumes/Command\ Line\ Developer\ Tools/Command\ Line\ Tools.pkg -target / 
   hdiutil unmount /Volumes/Command\ Line\ Developer\ Tools/

   sudo xcodebuild -license accept

The last command fails with xcrun: error: invalid active developer path (/Applications/Xcode.app/Contents/Developer), missing xcrun at: /Applications/Xcode.app/Contents/Developer/usr/bin/xcrun

xcrunis present in /usr/bin

ec2-user@ip-172-31-18-221 ~ % which xcrun 

/usr/bin/xcrun

ec2-user@ip-172-31-18-221 ~ % xcode-select --version 

xcode-select version 2384.

ec2-user@ip-172-31-18-221 ~ % sw_vers 

ProductName:	macOS
ProductVersion:	11.4
BuildVersion:	20F71

How to install Xcode 12.5 and it's command line tools on a headless system ?

Install Xcode 12.5 from the command line
 
 
Q