skip to Main Content

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


  1. 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 building

    Example:

    sudo xcode-select -s /Applications/Xcode_12.5.1.app

    Login or Signup to reply.
  2. 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.

          - task: CmdLine@2
            displayName: 'Set Xcode v14.1.0'
            condition: eq(variables['Agent.OS'], 'Darwin') # Only run this step on macOS
            inputs:
              script: echo '##vso[task.setvariable variable=MD_APPLE_SDK_ROOT;]'/Applications/Xcode_14.1.0.app;sudo xcode-select --switch /Applications/Xcode_14.1.0.app/Contents/Developer
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search