Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 4

How to select latest non-beta Xcode?

Solved! Go to Solution.

I'm using this, which selects Xcode_11.3.app but printing the xcodebuild version reveals that it's the beta build.

    - name: Select latest Xcode
      run: |
        sudo xcode-select --switch "/Applications/$(ls "/Applications" | grep "Xcode_[\.0-9]*app" | sort -V | tail -1)/Contents/Developer"
        xcodebuild -version
3 Replies
Highlighted
GitHub Partner
Message 2 of 4

Re: How to select latest non-beta Xcode?

Github-hosted runner support below xcode by default.

Please use below command to get the 11.2.1 version xcode.

sudo xcode-select --switch "/Applications/$(ls "/Applications" | grep "Xcode_[\.0-9]*app" | sort -V | tail -2 | head -1)/Contents/Developer"
xcodebuild -version

xcodeversionongithubrunner.pngxcodeselect.png

Highlighted
Copilot Lvl 3
Message 3 of 4

Re: How to select latest non-beta Xcode?

Sadly that only works when there is a beta version available. If the latest one is not beta then that will select the previous version.

I guess I have to look for Xcode_[\.0-9]*_.*app and then select the last -(x+1)th Xcode version based on the number of matches.

Highlighted
Solution
Copilot Lvl 3
Message 4 of 4

Re: How to select latest non-beta Xcode?

Ah, realized how the symlinks are structured, so basically we want to only grep the non-symlinks and then betas won't be included after the grep:

 

sudo xcode-select --switch "$(find /Applications -mindepth 1 -maxdepth 1 ! -type l | grep "Xcode_[\.0-9]*app" | sort -V | tail -1)/Contents/Developer"