skip to Main Content

I am trying to create a CI pipeline to run my unit tests. From the help of this stack overflow thread, Is there any way to run unit and ui tests for azure devops with iOS?, I have created my azure-pipelines.yml similarly

# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- master

pool:
  vmImage: 'macOS-10.15'

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'
- task: Xcode@5
  displayName: 'Running tests'
  inputs:
    actions: 'test'
    sdk: 'iphonesimulator'
    #configuration: 'Debug'
    #xcWorkspacePath: 'TeamDrawFramework/TeamDrawFramework.xcodeproj/project.xcworkspace'
    xcWorkspacePath: 'TeamDrawFramework/TeamDrawFramework.xcodeproj'
    scheme: 'TeamDrawFrameworkTests'
    xcodeVersion: 'default'
    useXcpretty: true
    publishJUnitResults: true
    destinationPlatformOption: 'iOS' # Optional. Options: default, iOS, tvOS, macOS, custom
    destinationPlatform: 'iOS Simulator'# Optional
    destinationTypeOption: 'simulators' # Optional. Options: simulators, devices
    destinationSimulators: 'iPhone 8' # Optional. Default value: iPhone8 for Xcode 11 and iPhone 7 for other iOS projects; Apple TV for tvOS projects.
- task: PublishTestResults@2
  displayName: 'Publishing test results'
  inputs:
    testResultsFormat: 'JUnit'
    testResultsFiles: '**/junit.xml'
    mergeTestResults: true
    failTaskOnFailedTests: true

But whenever my pipeline runs, I get the error message:

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

    Available destinations for the "TeamDrawFrameworkTests" scheme:
        { platform:macOS, arch:x86_64, variant:Mac Catalyst, id:4203018E-580F-C1B5-9525-B745CECA79EB }

    Ineligible destinations for the "TeamDrawFrameworkTests" scheme:
        { platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
        { platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device }
        { platform:macOS, variant:Mac Catalyst, name:Any Mac }
##[error]Error: /usr/bin/xcodebuild failed with return code: 70

I was able to run my tests from the command line fine through this command which essentially has the same flags set:

xcodebuild -project TeamDrawFramework/TeamDrawFramework.xcodeproj -scheme TeamDrawFrameworkTests -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 12,OS=14.5' test

I’m not sure exactly what the problem is, but because available destinations from the error message is so sparse I believe it’s an issue with the Azure VM.

TLDR: Why is the only available destination

    { platform:macOS, arch:x86_64, variant:Mac Catalyst, id:4203018E-580F-C1B5-9525-B745CECA79EB }

when there should be a list of iOS simulators available?

2

Answers


  1. Chosen as BEST ANSWER

    My projects deployment target was too high (even though my framework's target was fine). It was set to 14.5, but the current default Xcode version for the vmImage macOS 10.15 is 12.4, with simulators on iOS 14.4. After setting it to the same as my framework's target, 12.1, it worked fine.


  2. Based on your Yaml sample, you are using the macos 10.15.

    The iOS simulators are available in this agent.

    You could refer to this Agent configuration doc, then you could get all lists.

    xcodebuild: error: Unable to find a destination matching the provided destination specifier:

    The macos agent is using the Xcode 12.4 by default.

    So you could try to define the OS version(14.4) in the Xcode task.

    For example:

    - task: Xcode@5
      displayName: 'Running tests'
      inputs:
        actions: 'test'
        sdk: 'iphonesimulator'
        #configuration: 'Debug'
        #xcWorkspacePath: 'XXX'
        xcWorkspacePath: 'XXX'
        scheme: 'XXX'
        xcodeVersion: 'default'
        useXcpretty: true
        publishJUnitResults: true
        destinationPlatformOption: 'iOS' # Optional. Options: default, iOS, tvOS, macOS, custom
        destinationPlatform: 'iOS Simulator'# Optional
        destinationTypeOption: 'simulators' # Optional. Options: simulators, devices
        destinationSimulators: 'iPhone 8,OS=14.4'
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search