I am building a cross-platform C++ project which has unit tests written with googletest framework and there are issues I am facing when trying to run unit tests on iPhone simulator on Azure DevOps.

The problem is xcrun simctl launch executes application on iPhone simulator but it also seems to wait for simulator application to terminate in order to return back to console, so I tried to run it in background with & and wait for 30 seconds (which should be enough for unit tests to complete) and kill it, but it looks like & simply has no effect on Azure and pipeline simply stalls for ever and never reaches the sleep 30 instruction. I have looked through Azure documentation, but can't seem to find any clue.

At the same time the following script has been tested and proved to work locally. It boots the simulator, installs and launches the app, then kills sim after 30 seconds and downloads the output results.

- job: BuildJob
    vmImage: 'macOS-10.13'

  - template: ios-single-build.yml
      sdk: '11'
      arch: 'x86_64'
      config: ${{ parameters.config }}
      sysroot: 'iphonesimulator'

  - bash: |
      # npm install ios-sim -g
      UUID=`xcrun simctl list | grep 'iPhone X' | cut -d'(' -f2 | cut -d')' -f1 | grep -v apple | head -n 1`
      xcrun simctl boot $UUID
      xcrun simctl install booted $(Build.BinariesDirectory)/unit-tests/google_test.app
      xcrun simctl launch booted test.google.app >/dev/null 2>&1 &
      sleep 30
      kill %1
      OUT=`find ~/Library/Developer/CoreSimulator/Devices/$UUID/data/Containers/Data/Application/ -name test_results.txt`
      cat $OUT
    displayName: 'Run unit tests'

So are there really any limitations to not run processes in background on Azure? Are there any other ways how to run iPhone simulator? Btw, I have also tried the ios-sim utility, but it also waits for simulator to terminate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.