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 a373ab1..2c4b729 100755 --- a/test-apps/ios-test-app/scripts/build-and-deploy.sh +++ b/test-apps/ios-test-app/scripts/build-and-deploy.sh @@ -77,22 +77,36 @@ fi log_info "Using CocoaPods: $POD_CMD" -# Get simulator device (default to iPhone 15 Pro) -SIMULATOR_DEVICE="${1:-iPhone 15 Pro}" -log_info "Using simulator: $SIMULATOR_DEVICE" - -# Boot simulator -log_step "Booting simulator..." -if xcrun simctl list devices | grep -q "$SIMULATOR_DEVICE.*Booted"; then - log_info "Simulator already booted" -else - if xcrun simctl boot "$SIMULATOR_DEVICE" 2>/dev/null; then - log_info "✓ Simulator booted" +# Get simulator device (default to first available iPhone, or user-specified) +if [ -z "$1" ]; then + # Auto-detect first available iPhone simulator + SIMULATOR_DEVICE=$(xcrun simctl list devices available | grep -i "iPhone" | head -1 | sed 's/.*(\(.*\))/\1/' | xargs || echo "") + if [ -z "$SIMULATOR_DEVICE" ]; then + # Fallback to generic simulator + SIMULATOR_DEVICE="Any iOS Simulator Device" + log_warn "No iPhone simulators found, using generic destination" else - log_warn "Could not boot simulator automatically" - log_info "Opening Simulator app... (you may need to select device manually)" - open -a Simulator - sleep 5 + log_info "Auto-detected simulator: $SIMULATOR_DEVICE" + fi +else + SIMULATOR_DEVICE="$1" + log_info "Using specified simulator: $SIMULATOR_DEVICE" +fi + +# Boot simulator (only if specific device name provided) +if [ "$SIMULATOR_DEVICE" != "Any iOS Simulator Device" ] && [ "$SIMULATOR_DEVICE" != "generic/platform=iOS Simulator" ]; then + log_step "Booting simulator..." + if xcrun simctl list devices | grep -q "$SIMULATOR_DEVICE.*Booted"; then + log_info "Simulator already booted" + else + if xcrun simctl boot "$SIMULATOR_DEVICE" 2>/dev/null; then + log_info "✓ Simulator booted" + else + log_warn "Could not boot simulator automatically" + log_info "Opening Simulator app... (you may need to select device manually)" + open -a Simulator + sleep 5 + fi fi fi @@ -120,11 +134,20 @@ SCHEME="App" CONFIG="Debug" 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" +else + DESTINATION="platform=iOS Simulator,name=$SIMULATOR_DEVICE" +fi + +log_info "Build destination: $DESTINATION" + xcodebuild -workspace "$WORKSPACE" \ -scheme "$SCHEME" \ -configuration "$CONFIG" \ -sdk "$SDK" \ - -destination "platform=iOS Simulator,name=$SIMULATOR_DEVICE" \ + -destination "$DESTINATION" \ -derivedDataPath build/derivedData \ CODE_SIGN_IDENTITY='' \ CODE_SIGNING_REQUIRED=NO \