Switching Xcode Versions Without a Password
sudo xcodebuild -runFirstLaunchThis works fine locally, but when updating remote CI machines, entering the password can be troublesome. Furthermore if you want to support having CI machines automatically switch between Xcode versions when testing upcoming changes, you may not have the opportunity to be prompted at all. Lucky for us, the sudoers file format, which configures the
sudocommand, allows us to skip password entry for specific commands with a bit of configuration.[…]
- We specify just the
xcode-selectbinary, using the absolute path. This allows all subcommands handled byxcode-selectto be run without a password.- The
xcodebuildcommand also contains the one subcommand we want to be able to run without a password. Limiting this is important because otherwise you could runsudo xcodebuild buildwithout a password, which could execute malicious run scripts or do other terrible things.
1 Comment RSS · Twitter
I use:
   export DEVELOPER_DIR=$(PATHNAME_TO_XCODE_I_WANT) make target
My Intel Mac running Big Sur builds for Catalina, Big Sur and Monterey all with different versions of Xcode (to get the correct DriverKit API for each OS.)







