Skip to content

Commit 2e66e59

Browse files
committed
Programaticly select iOS simulator Runtime/Device
Signed-off-by: Joe Richey <joerichey@google.com>
1 parent 62e697f commit 2e66e59

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

.github/workflows/tests.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,15 @@ jobs:
9494
wget -O - $URL | tar -xz --strip-components=1 -C ~/.cargo/bin
9595
cargo dinghy --version
9696
- name: Setup Simulator
97+
# Use the first installed iOS runtime and the first (i.e. oldest) supported iPhone device.
9798
run: |
98-
RUNTIME_ID=$(xcrun simctl list runtimes | grep iOS | cut -d ' ' -f 7 | tail -1)
99-
SIM_ID=$(xcrun simctl create My-iphone7 com.apple.CoreSimulator.SimDeviceType.iPhone-7 $RUNTIME_ID)
99+
RUNTIME=$(xcrun simctl list runtimes --json | jq '.runtimes | map(select(.name | contains("iOS"))) | .[0]')
100+
RUNTIME_ID=$(echo $RUNTIME | jq -r '.identifier')
101+
echo "Using runtime:" $RUNTIME_ID
102+
DEVICE_ID=$(echo $RUNTIME | jq -r '.supportedDeviceTypes | map(select(.productFamily == "iPhone")) | .[0].identifier')
103+
echo "Using device:" $DEVICE_ID
104+
SIM_ID=$(xcrun simctl create Test-iPhone $DEVICE_ID $RUNTIME_ID)
105+
echo "Created simulator:" $SIM_ID
100106
xcrun simctl boot $SIM_ID
101107
echo "device=$SIM_ID" >> $GITHUB_ENV
102108
- uses: Swatinem/rust-cache@v2

0 commit comments

Comments
 (0)