Skip to content

Commit 3bdcc00

Browse files
fix: add timeout for simulator boot status check and ensure gtimeout is installed
1 parent 36644e3 commit 3bdcc00

3 files changed

Lines changed: 33 additions & 4 deletions

File tree

.github/scripts/launch-ios-simulator.sh

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,34 @@ else
180180
fi
181181

182182
# Final verification
183+
# `simctl bootstatus -b` occasionally hangs on CI even when the device is already Booted.
184+
# Guard it with a timeout so this script can never run forever.
183185
log_info "Verifying simulator status..."
184-
xcrun simctl bootstatus "$DEVICE_UDID" -b 2>/dev/null || {
185-
log_warning "bootstatus check failed (non-critical)"
186-
}
186+
if command -v gtimeout >/dev/null 2>&1; then
187+
gtimeout 60 xcrun simctl bootstatus "$DEVICE_UDID" -b 2>/dev/null || {
188+
log_warning "bootstatus check failed or timed out (non-critical)"
189+
}
190+
elif command -v timeout >/dev/null 2>&1; then
191+
timeout 60 xcrun simctl bootstatus "$DEVICE_UDID" -b 2>/dev/null || {
192+
log_warning "bootstatus check failed or timed out (non-critical)"
193+
}
194+
else
195+
# Best effort: run without a guard, but don't block the pipeline forever.
196+
xcrun simctl bootstatus "$DEVICE_UDID" -b 2>/dev/null &
197+
BOOTSTATUS_PID=$!
198+
for _ in $(seq 1 60); do
199+
if ! kill -0 "$BOOTSTATUS_PID" 2>/dev/null; then
200+
wait "$BOOTSTATUS_PID" || log_warning "bootstatus check failed (non-critical)"
201+
BOOTSTATUS_PID=""
202+
break
203+
fi
204+
sleep 1
205+
done
206+
if [ -n "${BOOTSTATUS_PID:-}" ]; then
207+
kill "$BOOTSTATUS_PID" 2>/dev/null || true
208+
log_warning "bootstatus check timed out (non-critical)"
209+
fi
210+
fi
187211

188212
# Print simulator info
189213
log_success "Simulator is ready!"

.github/workflows/ios.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ jobs:
7373
brew install jq
7474
fi
7575
76+
# Ensure `gtimeout` is available (coreutils) for robust timeouts on macOS.
77+
if ! command -v gtimeout &> /dev/null; then
78+
brew install coreutils
79+
fi
80+
7681
# Launch simulator with our custom script
7782
bash .github/scripts/launch-ios-simulator.sh "${{ env.DEVICE_MODEL }}" "${{ env.IOS_VERSION }}"
7883

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"build:android": "react-native build-android --extra-params \"--no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a\"",
1010
"build:ios": "react-native build-ios --mode Debug",
1111
"pod": "bundle install && bundle exec pod install --project-directory=ios",
12-
"app:package:ios": "xcodebuild -workspace ios/MendixNativeExample.xcworkspace -scheme MendixNativeExample -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 17,OS=latest' -derivedDataPath ios/build build",
12+
"app:package:ios": "xcodebuild -workspace ios/MendixNativeExample.xcworkspace -scheme MendixNativeExample -configuration Debug -sdk iphonesimulator -destination 'generic/platform=iOS Simulator' -derivedDataPath ios/build build",
1313
"app:install:ios": "xcrun simctl install booted ios/build/Build/Products/Debug-iphonesimulator/MendixNativeExample.app",
1414
"app:package:android": "(cd android && ./gradlew assembleDebug --no-daemon)",
1515
"app:install:android": "adb install -r android/app/build/outputs/apk/debug/app-debug.apk",

0 commit comments

Comments
 (0)