Skip to content

Commit 5bd1a05

Browse files
BrentMifsudclaude
andcommitted
Dynamically resolve simulator destinations in CI
Replace hardcoded simulator names and OS versions with dynamic discovery using xcrun simctl. Each simulator platform job now queries available devices at runtime and picks the first match, making CI resilient to runner image changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent bd573b2 commit 5bd1a05

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

.github/workflows/ci.yaml

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ jobs:
2323
command: swift test
2424
- platform: iOS
2525
runner: macos-latest
26-
command: xcodebuild test -scheme Simplicity -destination "platform=iOS Simulator,name=iPhone 17" -skipPackagePluginValidation
26+
sim_runtime: iOS
2727
- platform: tvOS
2828
runner: macos-latest
29-
command: xcodebuild test -scheme Simplicity -destination "platform=tvOS Simulator,name=Apple TV 4k (3rd generation)" -skipPackagePluginValidation
29+
sim_runtime: tvOS
3030
- platform: watchOS
3131
runner: macos-latest
32-
command: xcodebuild test -scheme Simplicity -destination "platform=watchOS Simulator,name=Apple Watch Ultra 3 (49mm)" -skipPackagePluginValidation
32+
sim_runtime: watchOS
3333
- platform: visionOS
3434
runner: macos-latest
35-
command: xcodebuild test -scheme Simplicity -destination "platform=visionOS Simulator,name=Apple Vision Pro" -skipPackagePluginValidation
35+
sim_runtime: visionOS
3636
- platform: Linux
3737
runner: ubuntu-latest
3838
container: swift:6.2
@@ -59,5 +59,37 @@ jobs:
5959
if: ${{ matrix.runner == 'macos-latest' }}
6060
run: xcodebuild -version
6161

62+
- name: Resolve simulator destination
63+
if: ${{ matrix.sim_runtime }}
64+
run: |
65+
RUNTIME="${{ matrix.sim_runtime }}"
66+
# visionOS runtimes may use 'xrOS' in the identifier
67+
case "$RUNTIME" in
68+
visionOS) PATTERN="visionOS|xrOS" ;;
69+
*) PATTERN="$RUNTIME" ;;
70+
esac
71+
72+
DEVICE_INFO=$(xcrun simctl list devices available -j | jq -r --arg p "$PATTERN" '
73+
[.devices | to_entries[] | select(.key | test($p)) | .value[] | select(.isAvailable == true)]
74+
| first | "\(.udid)|\(.name)"
75+
')
76+
77+
DEVICE_UDID="${DEVICE_INFO%%|*}"
78+
DEVICE_NAME="${DEVICE_INFO##*|}"
79+
80+
if [ "$DEVICE_UDID" = "null" ] || [ -z "$DEVICE_UDID" ]; then
81+
echo "::error::No available ${{ matrix.sim_runtime }} simulator found"
82+
xcrun simctl list devices available
83+
exit 1
84+
fi
85+
86+
echo "Resolved simulator: $DEVICE_NAME ($DEVICE_UDID)"
87+
echo "SIM_DESTINATION=platform=${{ matrix.sim_runtime }} Simulator,id=$DEVICE_UDID" >> "$GITHUB_ENV"
88+
6289
- name: Run tests
63-
run: ${{ matrix.command }}
90+
run: |
91+
if [ -n "$SIM_DESTINATION" ]; then
92+
xcodebuild test -scheme Simplicity -destination "$SIM_DESTINATION" -skipPackagePluginValidation
93+
else
94+
${{ matrix.command }}
95+
fi

0 commit comments

Comments
 (0)