@@ -54,7 +54,12 @@ ri_log "Loading workspace environment from $ENV_FILE"
5454source " $ENV_FILE "
5555
5656# Use the same Xcode as the build step
57- export DEVELOPER_DIR=" /Applications/Xcode_16.4.app/Contents/Developer"
57+ XCODE_APP=" ${XCODE_APP:-/ Applications/ Xcode_26.0.1.app} "
58+ if [ ! -d " $XCODE_APP " ]; then
59+ ri_log " Xcode 26 not found at $XCODE_APP . Set XCODE_APP to the Xcode 26 app bundle path." >&2
60+ exit 3
61+ fi
62+ export DEVELOPER_DIR=" $XCODE_APP /Contents/Developer"
5863export PATH=" $DEVELOPER_DIR /usr/bin:$PATH "
5964
6065if [ -z " ${JAVA17_HOME:- } " ] || [ ! -x " $JAVA17_HOME /bin/java" ]; then
@@ -475,6 +480,28 @@ APP_PROCESS_NAME="${WRAPPER_NAME%.app}"
475480 LOG_STREAM_PID=$!
476481 sleep 2
477482
483+ LAUNCH_LOG=" $ARTIFACTS_DIR /simctl-launch.log"
484+
485+ launch_simulator_app () {
486+ local target=" $1 "
487+ local attempt=1
488+ while true ; do
489+ local output
490+ if output=" $( xcrun simctl launch " $target " " $BUNDLE_IDENTIFIER " 2>&1 ) " ; then
491+ printf ' %s\n' " $output " >> " $LAUNCH_LOG "
492+ return 0
493+ fi
494+ printf ' %s\n' " [$( date -u +%Y-%m-%dT%H:%M:%SZ) ] simctl launch failed (attempt $attempt ): $output " >> " $LAUNCH_LOG "
495+ if [ " $attempt " -ge 2 ]; then
496+ return 1
497+ fi
498+ ri_log " simctl launch failed (attempt $attempt ), retrying"
499+ xcrun simctl bootstatus " $target " -b > /dev/null 2>&1 || true
500+ sleep 5
501+ attempt=$(( attempt + 1 ))
502+ done
503+ }
504+
478505 ri_log " Installing simulator app bundle"
479506 INSTALL_START=$( date +%s)
480507 if [ -n " $SIM_DEVICE_ID " ]; then
@@ -485,8 +512,8 @@ APP_PROCESS_NAME="${WRAPPER_NAME%.app}"
485512 INSTALL_END=$( date +%s)
486513
487514 LAUNCH_START=$( date +%s)
488- if ! xcrun simctl launch " $SIM_DEVICE_ID " " $BUNDLE_IDENTIFIER " > /dev/null 2>&1 ; then
489- ri_log " FATAL: simctl launch failed"
515+ if ! launch_simulator_app " $SIM_DEVICE_ID " ; then
516+ ri_log " FATAL: simctl launch failed (see $LAUNCH_LOG ) "
490517 exit 11
491518 fi
492519 LAUNCH_END=$( date +%s)
@@ -498,8 +525,8 @@ APP_PROCESS_NAME="${WRAPPER_NAME%.app}"
498525 INSTALL_END=$( date +%s)
499526
500527 LAUNCH_START=$( date +%s)
501- if ! xcrun simctl launch booted " $BUNDLE_IDENTIFIER " > /dev/null 2>&1 ; then
502- ri_log " FATAL: simctl launch failed"
528+ if ! launch_simulator_app booted; then
529+ ri_log " FATAL: simctl launch failed (see $LAUNCH_LOG ) "
503530 exit 11
504531 fi
505532 LAUNCH_END=$( date +%s)
@@ -659,4 +686,3 @@ cp -f "$BUILD_LOG" "$ARTIFACTS_DIR/xcodebuild-build.log" 2>/dev/null || true
659686cp -f " $TEST_LOG " " $ARTIFACTS_DIR /device-runner.log" 2> /dev/null || true
660687
661688exit $comment_rc
662-
0 commit comments