Skip to content

Commit 503f9b1

Browse files
committed
fix(mobile): support DeviceHub in mobile-dev
Signed-off-by: Tom Brow <[email protected]>
1 parent 60de1db commit 503f9b1

2 files changed

Lines changed: 42 additions & 3 deletions

File tree

‎Justfile‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,8 +1026,9 @@ mobile-build-android:
10261026
mobile-dev:
10271027
#!/usr/bin/env bash
10281028
set -euo pipefail
1029-
if ! pgrep -x Simulator &>/dev/null; then
1030-
open -a Simulator
1029+
# Xcode 27 replaced Simulator.app with DeviceHub.app.
1030+
if ! pgrep -x Simulator &>/dev/null && ! pgrep -x DeviceHub &>/dev/null; then
1031+
open -a Simulator 2>/dev/null || open -a DeviceHub
10311032
sleep 3
10321033
fi
10331034
./scripts/mobile-worktree-overrides.sh

‎scripts/test-mobile-gateway-recipes.sh‎

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,26 @@ printf '%s\n' "$@" > "$CALL_LOG"
1717
STUB
1818
cat > "$fixture/bin/pgrep" <<'STUB'
1919
#!/bin/bash
20+
[[ "$*" == "-x $RUNNING_APP" ]]
21+
STUB
22+
cat > "$fixture/bin/open" <<'STUB'
23+
#!/bin/bash
24+
printf '%s\n' "$*" >> "$OPEN_LOG"
25+
[[ "$*" == "-a $AVAILABLE_APP" ]]
26+
STUB
27+
cat > "$fixture/bin/sleep" <<'STUB'
28+
#!/bin/bash
2029
exit 0
2130
STUB
2231
cat > "$fixture/scripts/mobile-worktree-overrides.sh" <<'STUB'
2332
#!/bin/bash
2433
exit 0
2534
STUB
26-
chmod +x "$fixture/bin/flutter" "$fixture/bin/pgrep" "$fixture/scripts/mobile-worktree-overrides.sh"
35+
chmod +x "$fixture/bin/flutter" "$fixture/bin/pgrep" "$fixture/bin/open" "$fixture/bin/sleep" "$fixture/scripts/mobile-worktree-overrides.sh"
2736
export PATH="$fixture/bin:$PATH"
2837
export CALL_LOG="$fixture/arguments"
38+
export OPEN_LOG="$fixture/open-calls"
39+
export RUNNING_APP=DeviceHub AVAILABLE_APP=none
2940
unset BUZZ_PUSH_GATEWAY_URL
3041

3142
for recipe in mobile-dev mobile-build-android; do
@@ -56,3 +67,30 @@ printf '%s\n' 'BUZZ_PUSH_GATEWAY_URL = https:/$()/push.example' > "$fixture/mobi
5667
printf '%s\n' run '--dart-define=BUZZ_PUSH_GATEWAY_URL=https://push.example' > "$fixture/expected"
5768
diff -u "$fixture/expected" "$CALL_LOG"
5869
printf 'PASS mobile-dev Xcode override\n'
70+
71+
# Cover both supported Xcode app names, including launching a stopped app.
72+
for scenario in running-simulator running-devicehub launch-simulator launch-devicehub missing-app; do
73+
export RUNNING_APP=none AVAILABLE_APP=none
74+
case "$scenario" in
75+
running-simulator) RUNNING_APP=Simulator ;;
76+
running-devicehub) RUNNING_APP=DeviceHub ;;
77+
launch-simulator) AVAILABLE_APP=Simulator ;;
78+
launch-devicehub) AVAILABLE_APP=DeviceHub ;;
79+
esac
80+
rm -f "$CALL_LOG"
81+
: > "$OPEN_LOG"
82+
: > "$fixture/expected-open"
83+
case "$scenario" in
84+
launch-simulator) printf '%s\n' '-a Simulator' > "$fixture/expected-open" ;;
85+
launch-devicehub|missing-app) printf '%s\n' '-a Simulator' '-a DeviceHub' > "$fixture/expected-open" ;;
86+
esac
87+
if (cd "$fixture" && /bin/bash "$fixture/mobile-dev"); then
88+
[[ "$scenario" != missing-app ]]
89+
diff -u "$fixture/expected" "$CALL_LOG"
90+
else
91+
[[ "$scenario" == missing-app ]]
92+
[[ ! -e "$CALL_LOG" ]]
93+
fi
94+
diff -u "$fixture/expected-open" "$OPEN_LOG"
95+
printf 'PASS mobile-dev %s\n' "$scenario"
96+
done

0 commit comments

Comments
 (0)