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 764370c..7bcb84f 100755 --- a/test-apps/ios-test-app/scripts/build-and-deploy.sh +++ b/test-apps/ios-test-app/scripts/build-and-deploy.sh @@ -92,10 +92,16 @@ if [ -z "$1" ]; then # Extract device ID (UUID in first set of parentheses, not status in second) # Format: " iPhone 17 Pro (68D19D08-4701-422C-AF61-2E21ACA1DD4C) (Shutdown)" # We want the UUID, which is in the first parentheses - SIMULATOR_ID=$(echo "$SIMULATOR_LINE" | sed -n 's/.*(\([0-9A-F-]\{36\}\)).*/\1/p' | head -1) - if [ -z "$SIMULATOR_ID" ]; then - # Fallback: try to get first parentheses content (should be UUID) - SIMULATOR_ID=$(echo "$SIMULATOR_LINE" | sed -n 's/.*(\([^)]*\)).*/\1/p' | head -1) + # Try extended regex first (works on macOS sed) + SIMULATOR_ID=$(echo "$SIMULATOR_LINE" | sed -E 's/.*\(([0-9A-F-]{36})\).*/\1/' 2>/dev/null) + if [ -z "$SIMULATOR_ID" ] || [ "$SIMULATOR_ID" = "$SIMULATOR_LINE" ]; then + # Fallback: use basic regex to get first parentheses content + SIMULATOR_ID=$(echo "$SIMULATOR_LINE" | sed 's/.*(\([^)]*\)).*/\1/' | head -1) + # If that gives us "Shutdown" or similar status, try a different approach + if [ "$SIMULATOR_ID" = "Shutdown" ] || [ "$SIMULATOR_ID" = "Booted" ]; then + # Extract UUID by matching the pattern before the status + SIMULATOR_ID=$(echo "$SIMULATOR_LINE" | sed -E 's/.*\(([0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})\).*/\1/' 2>/dev/null) + fi fi log_info "Auto-detected simulator: $SIMULATOR_DEVICE (ID: $SIMULATOR_ID)" fi