1. Download Xcode from https://developer.apple.com/download/more/ (this requeires to Login in with an Apple Developer Account)
At the moment id don´t know how to authenticate so i have no clue to download the xip via curl/wget.
In my case i downloaded the file and copied it via scp to my mac.
eg. for Xcode 9.2 https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_9.2/Xcode_9.2.xip
pkgutil --verbose --check-signature path/to/xip
eg. pkgutil --verbose --check-signature Xcode_9.2.xip
xar -xf path/to/xip
eg. xar -xf Xcode_9.2.xip
curl -O https://gist.githubusercontent.com/pudquick/ff412bcb29c9c1fa4b8d/raw/24b25538ea8df8d0634a2a6189aa581ccc6a5b4b/parse_pbzx2.py
python parse_pbzx2.py Content
Locate all Concent.partXX.cpio.xz file with more than 0Bytes and decompress them
xz -d Content.partXX.cpio.xz
for i in *.cpio; do cat $i >> Content.cpio; done
sudo cpio -idm < Content.cpio
sudo mv ./Xcode.app /Applications/
@YogiKhan you are absolutely 💯 correct.
BTW I would like to mention https://docs.fastlane.tools/actions/xcode_install/ for headless installation of XCode which is my preferred method right now.