Maintaining Xcode on a CI server has always been a hassle.
Over the past we suffered through different solutions, from connection via VNC and updating Xcode with the Mac App Store, to manually downloading Xcode from the Developer Portal.
Luckily there is a RubyGem Xcode-Install to install/update Xcode, and has a comfortable fastlane integration. (We will cover more of fastlane very soon 😉 )
For our projects we created a lane to update Xcode locally and on CI servers:
# Fetch all available Xcode versions
# List all available Xcode versions
# Get version from parameter or prompt
version=options[:xcode_version]||prompt(text:"Enter the version: ")
So we can pass the version as a parameter:
If not, we get the prompt:
As we already using Jenkins for our other builds, I wanted to create a job for updating Xcode as well.
The only problem, the xcode-install gem requires the user-password during the installation.
I thought of several solutions, but all of them don’t sound really secure:
Run Jenkins as root user
Allow sudo without password prompt
In the end I found a better solution. It’s possible to pipe the password into sudo and execute fastlane: