Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/setup_simulator/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
15 changes: 12 additions & 3 deletions scripts/setup_simulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ get_runtime() {
visionOS) sdk_name="xrsimulator" ;;
esac

# 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
Expand All @@ -49,11 +52,11 @@ get_runtime() {

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)
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"
Expand All @@ -70,9 +73,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-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 || true

local created=false
for device_type in "${device_types[@]}"; do
echo "📲 Attempting to create '$sim_name' with type '$device_type' and runtime '$runtime'..."
Expand Down
4 changes: 2 additions & 2 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading