From bc90b10e99fd2090a9a9484dafe5925b604ca022 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sun, 5 Jul 2026 13:20:58 +0700 Subject: [PATCH] ci(ios): fall back to an existing simulator when the runtime download fails --- .github/workflows/ios-tests.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ios-tests.yml b/.github/workflows/ios-tests.yml index 563b7cb6c..8ddfb6f32 100644 --- a/.github/workflows/ios-tests.yml +++ b/.github/workflows/ios-tests.yml @@ -44,9 +44,24 @@ jobs: run: brew list xcbeautify &>/dev/null || brew install xcbeautify # macos-26 lazy-loads simulator runtimes; -downloadPlatform pulls the runtime - # matching Xcode's SDK and is a no-op when it is already present. + # matching Xcode's SDK and is a no-op when it is already present. The download + # endpoint flakes on hosted runners, so a failure falls back to checking whether + # the test device already exists before failing the job. - name: Install iOS simulator runtime - run: sudo xcodebuild -downloadPlatform iOS + run: | + if sudo xcodebuild -downloadPlatform iOS; then + exit 0 + fi + + echo "::warning::xcodebuild -downloadPlatform iOS failed; checking for an existing simulator" + device_name="$(echo "$TEST_DESTINATION" | sed -n 's/.*name=\([^,]*\).*/\1/p')" + if xcrun simctl list devices available | grep -qF "$device_name ("; then + echo "$device_name simulator is already available; continuing." + exit 0 + fi + + echo "::error::$device_name simulator is not available and the runtime download failed." + exit 1 # Secrets.xcconfig is gitignored. Tests do not need analytics keys, so the # checked-in example template is enough for the project to resolve.