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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user