You need a simulator for your Xcode UI tests that is not available on the stack that you are using. For example, you wish to run a simulator for an older iOS version.
Add the following code in a Script Step (replace 'iOS 13' with the version you need):
gem install xcode-install xcversion simulators --install='iOS 13'
Note: this does not work for Xcode 14 onwards, as Apple changed how simulators get installed (the previous version can still use this).
For Xcode 14 (and newer versions), there are two ways of downloading additional simulators.
Download iPhone simulators
You can use the xcodes command to install the simulators.
Add the following code in a Script Step (replace 'iOS 15.5' with the version you need):
# fail if any commands fails
# install xcodes
brew tap robotsandpencils/made
brew install robotsandpencils/made/xcodes
# Install iOS 15 simulator
sudo xcodes runtimes install "iOS 15.5"
For tvOS and watchOS, you can download the simulator with the following command based on Apple's official document:
xcrun simctl runtime add
And here's the list of all available tvOS and watchOS simulator runtimes: https://developer.apple.com/download/all/?q=Simulator%20Runtime