#!/bin/bash # Start WDA on device and ensure iproxy is running UDID="00008110-001A34303AE9801E" WDA_PORT=8100 WDA_PROJECT="/Users/woan/.appium/node_modules/appium-xcuitest-driver/node_modules/appium-webdriveragent" # Check if WDA is already responding if curl -s --connect-timeout 3 http://localhost:$WDA_PORT/status | grep -q '"ready" : true'; then echo "WDA already running" exit 0 fi echo "WDA not running, starting..." # Kill stale iproxy pkill -f "iproxy $WDA_PORT" 2>/dev/null sleep 1 # Start iproxy in background iproxy $WDA_PORT $WDA_PORT -u $UDID & IPROXY_PID=$! sleep 1 # Start WDA test runner in background xcodebuild test-without-building \ -project "$WDA_PROJECT/WebDriverAgent.xcodeproj" \ -scheme WebDriverAgentRunner \ -destination "id=$UDID" \ -allowProvisioningUpdates \ > /tmp/wda_output.log 2>&1 & WDA_PID=$! echo "WDA PID: $WDA_PID, iproxy PID: $IPROXY_PID" # Wait for WDA to become ready (max 60s) for i in $(seq 1 30); do sleep 2 if curl -s --connect-timeout 2 http://localhost:$WDA_PORT/status | grep -q '"ready" : true'; then echo "WDA started successfully after ${i}x2 seconds" exit 0 fi done echo "ERROR: WDA failed to start within 60s" echo "Last log lines:" tail -20 /tmp/wda_output.log exit 1