From ceb81a6be1fa741a4d3ce5743b56df624fa66f9f Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Tue, 11 Nov 2025 19:59:38 -0800 Subject: [PATCH] fix(ios): improve simulator boot detection and error handling Enhanced simulator boot logic for better reliability: Boot Detection: - More robust check for already-booted simulators - Uses grep with case-insensitive matching - Verifies boot status after manual Simulator app opening Error Handling: - Shows actual boot command output (removed 2>/dev/null) - Adds 3-second wait after successful boot for initialization - Verifies boot status after opening Simulator app manually - Continues with build even if boot verification fails Fixes: - Simulator boot detection now works correctly - Better error messages when boot fails - Handles edge cases where simulator is already booted Result: Build script now reliably detects and boots simulators --- .../ios-test-app/scripts/build-and-deploy.sh | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/test-apps/ios-test-app/scripts/build-and-deploy.sh b/test-apps/ios-test-app/scripts/build-and-deploy.sh index bd2d5ae..3b68658 100755 --- a/test-apps/ios-test-app/scripts/build-and-deploy.sh +++ b/test-apps/ios-test-app/scripts/build-and-deploy.sh @@ -97,16 +97,29 @@ fi # Boot simulator (only if specific device name provided) if [ "$SIMULATOR_DEVICE" != "Any iOS Simulator Device" ] && [ "$SIMULATOR_DEVICE" != "generic/platform=iOS Simulator" ]; then log_step "Booting simulator..." - if xcrun simctl list devices | grep -q "$SIMULATOR_DEVICE.*Booted"; then - log_info "Simulator already booted" + + # Check if simulator is already booted (more robust check) + BOOTED=$(xcrun simctl list devices | grep "$SIMULATOR_DEVICE" | grep -i "Booted" || echo "") + + if [ -n "$BOOTED" ]; then + log_info "✓ Simulator already booted: $SIMULATOR_DEVICE" else - if xcrun simctl boot "$SIMULATOR_DEVICE" 2>/dev/null; then - log_info "✓ Simulator booted" + log_info "Booting $SIMULATOR_DEVICE..." + # Try to boot by device name first + if xcrun simctl boot "$SIMULATOR_DEVICE" 2>&1; then + log_info "✓ Simulator booted successfully" + # Wait a moment for simulator to fully initialize + sleep 3 else log_warn "Could not boot simulator automatically" log_info "Opening Simulator app... (you may need to select device manually)" open -a Simulator sleep 5 + # Verify it's booted after opening + BOOTED=$(xcrun simctl list devices | grep "$SIMULATOR_DEVICE" | grep -i "Booted" || echo "") + if [ -z "$BOOTED" ]; then + log_warn "Simulator may not be booted. Continuing anyway..." + fi fi fi fi