I encountered an error in Jenkins while executing a job named UITestsJob which runs UI tests. This UITestsJob is pipeline job and its definition is in Jenkinsfile. Additioanally, I have another jobs in the same workspace and sometimes these jobs starts at the same time with this UITestsJob. I guess when two jobs starts at the same time I get this error:
UITestsJob-Runner.app encountered an error (Failed to install or launch the test runner. (Underlying error: The operation couldn’t be completed. (DVTCoreSimulatorAdditionsErrorDomain error 0.)))
I have already done cleaning step at the beginning of the pipeline, which is
sh 'rm -rf output'
sh 'rm -rf "$DERIVED_DATA_DIR"'
sh 'rm -rf "$PWD/Pods/"'
sh 'rm -rf ~/Library/Caches/CocoaPods
And after that I am installing pod with cleaning caches which is
sh '(pod cache clean --all --verbose && pod install)'
After I get error, I run these commands from terminal
xcrun simctl shutdown all
xcrun simctl erase all
And this error is gone. I do not want to include this into my pipeline file, since at the same time there could be other simulators that are running for other jobs. I can not find any solution other than erasing all of the simulators from terminal. Is there any permanent solution for this error? How can I fix this issue and after I can always trust that my job is running without breaking down because of 'TestRunner' error?