Home > Software engineering >  How to use specific iOS version on Azure hosted agent?
How to use specific iOS version on Azure hosted agent?

Time:03-16

I have a requirement to use exactly iOS 14.5 on our pipeline.

I tried the following:

variables:
  sdk: 'iphoneos14.5' // I also tried to iphoneos

- task: Xcode@5
  inputs:
    actions: 'test'
    configuration: '$(configuration)'
    sdk: '$(sdk)'
    xcWorkspacePath: 'MyProject.xcworkspace'
    scheme: '$(secondaryScheme)'
    xcodeVersion: 'specifyPath'
    xcodeDeveloperDir: '/Applications/Xcode_13.2.1.app'
    packageApp: false
    destinationPlatformOption: 'iOS'
    destinationSimulators: 'iPhone 11,OS=14.5'
    args: '-derivedDataPath $(agent.buildDirectory)/DerivedData'

But both runs failed with

xcodebuild: error: SDK "iphoneos14.5" cannot be located.
##[error]Error: /usr/bin/xcodebuild failed with return code: 64

And

xcodebuild: error: Unable to find a destination matching the provided destination specifier:
        { platform:iOS Simulator, OS:14.5, name:iPhone 11 }

That's what I understood from reading the preinstalled software documentation. enter image description here

I think below YAML file will help you understand why the official document said 'iOS 14.5' is supported but you can't use it.

pool:
  name: Azure Pipelines
#Your build pipeline references an undefined variable named ‘secondaryScheme’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972

steps:
- script: |
   xcodebuild -showsdks
   
   echo "========================================================="
   
   sudo xcode-select -switch /Applications/Xcode_12.5.1.app/Contents/Developer
   
   xcodebuild -showsdks
  displayName: 'Command Line Script'

When you see the result of the pipeline run, I believe you will understand everything:

enter image description here

After switching the version, you should be able to use the specific IOS version you want.

Reference: https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/customizing_the_notarization_workflow

You upload your app for notarization using notarytool command line tool. Xcode 13 or later supports this tool, so if you have more than one version of Xcode installed on your Mac, be sure to use the xcode-select utility to choose an appropriate version:

% sudo xcode-select -s /path/to/Xcode13.app

CodePudding user response:

Added this step

gem install xcode-install
xcversion simulators --install='iOS 13.5'

If someone finds a way to use the installed sdk for other Xcode, please comment here

  • Related