I use an CmdLine@2 task in my azure DevOps pipeline and trying to build the app, but unfortunately the Xcode Build job failed. I’m using SwiftUI classes which need to be at least build with Xcode 12.5, but the azure DevOps agent uses Xcode 12.4 version which causes the failure.
How can I still using the CmdLine@2 task, determine the Xcode version?
Here is the code of the .yml:
- task: CmdLine@2
displayName: 'Xcode Build'
inputs:
script: |
echo "Build iOS app"
cd $(Build.SourcesDirectory)
/usr/bin/xcodebuild -workspace '$(workspace)' -scheme '$(schemeName)' build -allowProvisioningUpdates CODE_SIGN_STYLE=Manual DEVELOPMENT_TEAM='$(developmentTeam)' CODE_SIGN_IDENTITY='$(signingIdentity)' APP_PROFILE='$(***Profile)' EXTENSION_PROFILE_FW='$(***FavWidProvProfile)' EXTENSION_PROFILE_NCW='$(***NCWidProvProfile)'
I’m using the CmdLine task, because the current version of the Xcode@5 task has limitations to build the application with multiple App extensions.
2
Answers
Depending on the agent that you are using check it’s README to see where each Xcode version is located, for example macos-11
Then use
xcode-select
to select the version you want before buildingExample:
sudo xcode-select -s /Applications/Xcode_12.5.1.app
The other answer is no longer valid now that Azure Pipelines uses
MD_APPLE_SDK_ROOT
to define the current selected version of Xcode.Below is the
CmdLine@2
step to set the version of Xcode to 14.1.0.In your Azure Pipeline configuration, replace
14.1.0
with the version of Xcode you wish to set as the default version.