From 6ae51521f9a80fe638b4750e4c42bd5158402891 Mon Sep 17 00:00:00 2001 From: Nick Cooke Date: Wed, 28 Oct 2026 14:41:54 -0400 Subject: [PATCH 1/3] fix(ci): harden simulator setup script and runtime matching --- .github/actions/setup_simulator/action.yml | 2 +- scripts/setup_simulator.sh | 20 ++++++++++++++++---- scripts/test.sh | 4 ++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/actions/setup_simulator/action.yml b/.github/actions/setup_simulator/action.yml index 1bb56b9a6..3eecbe12c 100644 --- a/.github/actions/setup_simulator/action.yml +++ b/.github/actions/setup_simulator/action.yml @@ -34,4 +34,4 @@ runs: env: PLATFORM: ${{ inputs.platform }} run: | - "$GITHUB_WORKSPACE/scripts/setup_simulator.sh" "$PLATFORM" + bash "$GITHUB_WORKSPACE/scripts/setup_simulator.sh" "$PLATFORM" diff --git a/scripts/setup_simulator.sh b/scripts/setup_simulator.sh index fa049766b..3d01b86d2 100755 --- a/scripts/setup_simulator.sh +++ b/scripts/setup_simulator.sh @@ -38,22 +38,28 @@ get_runtime() { visionOS) sdk_name="xrsimulator" ;; esac + local target_major_minor="" local target_major="" if [[ -n "$sdk_name" ]]; then local sdk_ver sdk_ver=$(xcrun --sdk "$sdk_name" --show-sdk-version 2>/dev/null || true) if [[ -n "$sdk_ver" ]]; then target_major="${sdk_ver%%.*}" + target_major_minor=$(echo "$sdk_ver" | grep -oE '^[0-9]+\.[0-9]+' || true) fi fi local runtime="" - if [[ -n "$target_major" ]]; then - runtime=$(xcrun simctl list runtimes available | grep "^${platform_prefix} ${target_major}\." | grep -o "com\.apple\.CoreSimulator\.SimRuntime\.${platform_prefix}-[0-9-]*" | tail -n 1 || true) + if [[ -n "$target_major_minor" ]]; then + runtime=$(xcrun simctl list runtimes available | grep -E "^[[:space:]]*${platform_prefix} ${target_major_minor//./\.}([^0-9]|$)" | grep -o "com\.apple\.CoreSimulator\.SimRuntime\.${platform_prefix}-[0-9-]*" | tail -n 1 || true) + fi + + if [[ -z "$runtime" && -n "$target_major" ]]; then + runtime=$(xcrun simctl list runtimes available | grep "^[[:space:]]*${platform_prefix} ${target_major}\." | grep -o "com\.apple\.CoreSimulator\.SimRuntime\.${platform_prefix}-[0-9-]*" | tail -n 1 || true) fi if [[ -z "$runtime" ]]; then - runtime=$(xcrun simctl list runtimes available | grep "^${platform_prefix}" | grep -o "com\.apple\.CoreSimulator\.SimRuntime\.${platform_prefix}-[0-9-]*" | tail -n 1 || true) + runtime=$(xcrun simctl list runtimes available | grep "^[[:space:]]*${platform_prefix}" | grep -o "com\.apple\.CoreSimulator\.SimRuntime\.${platform_prefix}-[0-9-]*" | tail -n 1 || true) fi echo "$runtime" @@ -70,9 +76,15 @@ create_sim() { return 0 fi - if xcrun simctl list devices available | grep -q "${sim_name} ("; then + if xcrun simctl list devices available | grep -Fq "${sim_name} ("; then echo "โœ… Simulator '$sim_name' already exists and is available." else + # Clean up any existing (but unavailable) simulators with the same name to avoid duplicates + xcrun simctl list devices | grep -F "${sim_name} (" | grep -oE '[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}' | while read -r uuid; do + echo "๐Ÿงน Removing existing/unavailable simulator $uuid..." + xcrun simctl delete "$uuid" || true + done + local created=false for device_type in "${device_types[@]}"; do echo "๐Ÿ“ฒ Attempting to create '$sim_name' with type '$device_type' and runtime '$runtime'..." diff --git a/scripts/test.sh b/scripts/test.sh index d37832248..d51922ae7 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -53,8 +53,8 @@ if [[ -z "${TEST:-}" ]]; then fi if [[ "$OS" == "iOS" || "$OS" == "tvOS" || "$OS" == "watchOS" ]]; then - if ! xcrun simctl list devices available | grep -q "${DEVICE} ("; then - ./scripts/setup_simulator.sh "$OS" + if [[ "$DEVICE" == Firebase-* ]] && ! xcrun simctl list devices available | grep -Fq "${DEVICE} ("; then + bash ./scripts/setup_simulator.sh "$OS" fi fi From d8c9aa5068ba7eaacf113f92e5dfc521bbf23793 Mon Sep 17 00:00:00 2001 From: Nick Cooke Date: Wed, 28 Oct 2026 15:33:06 -0400 Subject: [PATCH 2/3] fix(ci): handle non-existent simulator in cleanup pipeline and refine regexes --- scripts/setup_simulator.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/setup_simulator.sh b/scripts/setup_simulator.sh index 3d01b86d2..c72c49ee8 100755 --- a/scripts/setup_simulator.sh +++ b/scripts/setup_simulator.sh @@ -45,13 +45,15 @@ get_runtime() { sdk_ver=$(xcrun --sdk "$sdk_name" --show-sdk-version 2>/dev/null || true) if [[ -n "$sdk_ver" ]]; then target_major="${sdk_ver%%.*}" - target_major_minor=$(echo "$sdk_ver" | grep -oE '^[0-9]+\.[0-9]+' || true) + if [[ "$sdk_ver" =~ ^[0-9]+\.[0-9]+ ]]; then + target_major_minor="${BASH_REMATCH[0]}" + fi fi fi local runtime="" if [[ -n "$target_major_minor" ]]; then - runtime=$(xcrun simctl list runtimes available | grep -E "^[[:space:]]*${platform_prefix} ${target_major_minor//./\.}([^0-9]|$)" | grep -o "com\.apple\.CoreSimulator\.SimRuntime\.${platform_prefix}-[0-9-]*" | tail -n 1 || true) + runtime=$(xcrun simctl list runtimes available | grep -E "^[[:space:]]*${platform_prefix} ${target_major_minor//./\\.}([^0-9]|$)" | grep -o "com\.apple\.CoreSimulator\.SimRuntime\.${platform_prefix}-[0-9-]*" | tail -n 1 || true) fi if [[ -z "$runtime" && -n "$target_major" ]]; then @@ -80,10 +82,10 @@ create_sim() { echo "โœ… Simulator '$sim_name' already exists and is available." else # Clean up any existing (but unavailable) simulators with the same name to avoid duplicates - xcrun simctl list devices | grep -F "${sim_name} (" | grep -oE '[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}' | while read -r uuid; do + xcrun simctl list devices | grep -F "${sim_name} (" | grep -oE '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}' | while read -r uuid; do echo "๐Ÿงน Removing existing/unavailable simulator $uuid..." xcrun simctl delete "$uuid" || true - done + done || true local created=false for device_type in "${device_types[@]}"; do From f4a8799ca45df0649a5ca8d86b5efa35e54b216a Mon Sep 17 00:00:00 2001 From: Nick Cooke Date: Thu, 29 Oct 2026 11:16:20 -0400 Subject: [PATCH 3/3] fix(ci): match latest SDK major simulator runtime to align with xcodebuild OS:latest --- scripts/setup_simulator.sh | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/scripts/setup_simulator.sh b/scripts/setup_simulator.sh index c72c49ee8..b3b5e9b8a 100755 --- a/scripts/setup_simulator.sh +++ b/scripts/setup_simulator.sh @@ -38,25 +38,20 @@ get_runtime() { visionOS) sdk_name="xrsimulator" ;; esac - local target_major_minor="" + # Match the latest installed runtime for the active SDK's major version so it + # aligns with xcodebuild's implicit `OS:latest` destination resolution (e.g., + # selecting iOS 26.5 on macos-26 when 26.2, 26.4, and 26.5 are installed). local target_major="" if [[ -n "$sdk_name" ]]; then local sdk_ver sdk_ver=$(xcrun --sdk "$sdk_name" --show-sdk-version 2>/dev/null || true) if [[ -n "$sdk_ver" ]]; then target_major="${sdk_ver%%.*}" - if [[ "$sdk_ver" =~ ^[0-9]+\.[0-9]+ ]]; then - target_major_minor="${BASH_REMATCH[0]}" - fi fi fi local runtime="" - if [[ -n "$target_major_minor" ]]; then - runtime=$(xcrun simctl list runtimes available | grep -E "^[[:space:]]*${platform_prefix} ${target_major_minor//./\\.}([^0-9]|$)" | grep -o "com\.apple\.CoreSimulator\.SimRuntime\.${platform_prefix}-[0-9-]*" | tail -n 1 || true) - fi - - if [[ -z "$runtime" && -n "$target_major" ]]; then + if [[ -n "$target_major" ]]; then runtime=$(xcrun simctl list runtimes available | grep "^[[:space:]]*${platform_prefix} ${target_major}\." | grep -o "com\.apple\.CoreSimulator\.SimRuntime\.${platform_prefix}-[0-9-]*" | tail -n 1 || true) fi