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 7775aeb..eb9a5b1 100755 --- a/test-apps/ios-test-app/scripts/build-and-deploy.sh +++ b/test-apps/ios-test-app/scripts/build-and-deploy.sh @@ -81,13 +81,17 @@ log_info "Using CocoaPods: $POD_CMD" if [ -z "$1" ]; then # Auto-detect first available iPhone simulator # Extract device name from: " iPhone 17 Pro (UUID) (Status)" - SIMULATOR_DEVICE=$(xcrun simctl list devices available | grep -i "iPhone" | head -1 | sed 's/^[[:space:]]*\([^(]*\).*/\1/' | xargs || echo "") - if [ -z "$SIMULATOR_DEVICE" ]; then + SIMULATOR_LINE=$(xcrun simctl list devices available | grep -i "iPhone" | head -1) + if [ -z "$SIMULATOR_LINE" ]; then # Fallback to generic simulator SIMULATOR_DEVICE="generic/platform=iOS Simulator" log_warn "No iPhone simulators found, using generic destination" else - log_info "Auto-detected simulator: $SIMULATOR_DEVICE" + # Extract device name (everything before the first parenthesis) + SIMULATOR_DEVICE=$(echo "$SIMULATOR_LINE" | sed 's/^[[:space:]]*\([^(]*\).*/\1/' | xargs) + # Extract device ID (UUID in parentheses) + SIMULATOR_ID=$(echo "$SIMULATOR_LINE" | sed -n 's/.*(\([^)]*\)).*/\1/p' | head -1) + log_info "Auto-detected simulator: $SIMULATOR_DEVICE (ID: $SIMULATOR_ID)" fi else SIMULATOR_DEVICE="$1" @@ -157,7 +161,12 @@ SDK="iphonesimulator" # Use generic destination if device name is generic, otherwise use specific device if [ "$SIMULATOR_DEVICE" = "Any iOS Simulator Device" ] || [ "$SIMULATOR_DEVICE" = "generic/platform=iOS Simulator" ]; then DESTINATION="generic/platform=iOS Simulator" +elif [ -n "$SIMULATOR_ID" ]; then + # Use device ID for more reliable matching + DESTINATION="platform=iOS Simulator,id=$SIMULATOR_ID" + log_info "Using device ID for destination: $SIMULATOR_ID" else + # Fallback to device name DESTINATION="platform=iOS Simulator,name=$SIMULATOR_DEVICE" fi