Lucas LannesPosted on 3/17/2025

Running the iOS Simulator on CI/CD Pipelines

#iosdevelopment#xcode#iossimulator#swift#cicd

Select the iOS simulator

The command below will store the UDID in the current environment variables to be used later.

UDID=$(xcrun simctl list devices | grep "$IOS_SIMULATOR (" | grep -oE "[0-9A-F\-]{36}" | head -n 1)

Replace $IOS_SIMULATOR with the desired device such as iPhone SE (3rd generation), iPhone 15, iPhone 16 Pro etc.

You can check the available devices using the command xcrun simctl list devices.

Replace head -n 1 with sed -n '2p' if, for example, you want the second device returned by the grep command (because the same device can have multiple iOS versions available).

Run the iOS simulator

xcrun simctl boot "$UDID"
open -a Simulator

Check the iOS simulator

Before using the simulator, it's better to first check if it booted successfully.

xcrun simctl bootstatus "$UDID" -b

Install an application in iOS simulator

First, build your application for a simulator as the target in Xcode, since you can't install an .ipa file on the simulator.

xcodebuild -workspace "${APP_WORKSPACE}.xcworkspace" \
  -scheme "${APP_SCHEME}" \
  -sdk iphonesimulator \
  -configuration Release \
  -derivedDataPath build

Then, install the application in the iOS simulator, ensuring that $APP_BUILD_PATH points to an .app directory previously built for a simulator as the target in Xcode.

xcrun simctl install booted "$APP_BUILD_PATH"

Run iOS simulator on CI/CD pipelines

Below is the complete solution that will work on macOS agents in CI/CD environments.

# Select the iOS simulator
UDID=$(xcrun simctl list devices | grep "$IOS_SIMULATOR (" | grep -oE "[0-9A-F\-]{36}" | head -n 1)

# Run the iOS simulator
xcrun simctl boot "$UDID"
open -a Simulator

# Check the iOS simulator
xcrun simctl bootstatus "$UDID" -b

# Install an application in iOS simulator
xcrun simctl install booted "$APP_BUILD_PATH"

The commands above were tested in Azure Pipelines running on macOS-14 agent.

Read next

Lucas LannesPosted on 3/18/2025

Running the Android Emulator on CI/CD Pipelines

#androidemulator#cicd#mobiledevelopment#androiddevelopment#devops