From 676b17adb0aef20b8f2c83be22fafe4a0f8bc55c Mon Sep 17 00:00:00 2001 From: Moby Date: Thu, 19 Nov 2026 14:50:24 +0000 Subject: [PATCH 01/10] MBL-2804: give scene e2e destination waits a 60s budget --- .maestro/scene_push_declined.yaml | 2 +- .maestro/scene_push_open.yaml | 2 +- .maestro/scene_push_warm.yaml | 2 +- .maestro/scene_url_open.yaml | 6 ++++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.maestro/scene_push_declined.yaml b/.maestro/scene_push_declined.yaml index 14009005..341dbbfe 100644 --- a/.maestro/scene_push_declined.yaml +++ b/.maestro/scene_push_declined.yaml @@ -11,6 +11,6 @@ name: React Native UIScene declined app-owned URL retryTapIfNoChange: false - extendedWaitUntil: visible: 'Declined count: 1' - timeout: 15000 + timeout: 60000 - assertVisible: 'Received: cio-rn-scene-e2e://declined' - assertNotVisible: 'Declined count: 2' diff --git a/.maestro/scene_push_open.yaml b/.maestro/scene_push_open.yaml index 0b6d58c6..98994add 100644 --- a/.maestro/scene_push_open.yaml +++ b/.maestro/scene_push_open.yaml @@ -11,4 +11,4 @@ name: React Native UIScene cold push routing, open retryTapIfNoChange: false - extendedWaitUntil: visible: "Received: https://customer.io/react-native-scene-e2e/cold" - timeout: 15000 + timeout: 60000 diff --git a/.maestro/scene_push_warm.yaml b/.maestro/scene_push_warm.yaml index 70a7ab36..fd9b0871 100644 --- a/.maestro/scene_push_warm.yaml +++ b/.maestro/scene_push_warm.yaml @@ -11,4 +11,4 @@ name: React Native UIScene warm push routing retryTapIfNoChange: false - extendedWaitUntil: visible: "Received: https://customer.io/react-native-scene-e2e/warm" - timeout: 15000 + timeout: 60000 diff --git a/.maestro/scene_url_open.yaml b/.maestro/scene_url_open.yaml index 00e32a64..df0bdfdb 100644 --- a/.maestro/scene_url_open.yaml +++ b/.maestro/scene_url_open.yaml @@ -6,6 +6,8 @@ name: React Native UIScene ordinary URL optional: true - extendedWaitUntil: visible: 'Customer.io React Native scene E2E ready' - timeout: 15000 + timeout: 60000 - assertVisible: 'Routing: acknowledged' -- assertVisible: 'Received: ${EXPECTED_URL}' +- extendedWaitUntil: + visible: 'Received: ${EXPECTED_URL}' + timeout: 60000 From 8cf0ce4552cd3cdd5038bae27eb6ba40eb6b8da6 Mon Sep 17 00:00:00 2001 From: Moby Date: Thu, 19 Nov 2026 17:03:34 +0000 Subject: [PATCH 02/10] MBL-2804: give the scene e2e launch wait the same 60s budget --- .maestro/scene_push_prepare.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.maestro/scene_push_prepare.yaml b/.maestro/scene_push_prepare.yaml index 76c06bec..f14b5dea 100644 --- a/.maestro/scene_push_prepare.yaml +++ b/.maestro/scene_push_prepare.yaml @@ -9,5 +9,5 @@ name: React Native UIScene push routing, prepare notifications: allow - extendedWaitUntil: visible: 'Customer.io React Native scene E2E ready' - timeout: 15000 + timeout: 60000 - assertVisible: 'Routing: ${ROUTING_MODE}' From c4aebd6142e190e3eed368909c04439b2e52f7b2 Mon Sep 17 00:00:00 2001 From: Moby Date: Thu, 19 Nov 2026 17:30:19 +0000 Subject: [PATCH 03/10] MBL-2804: open the warm scene url from inside the running maestro flow --- .maestro/run_scene_push.sh | 80 ++++++++++++++++++++++++------------ .maestro/scene_url_open.yaml | 3 -- .maestro/scene_url_warm.yaml | 16 ++++++++ 3 files changed, 70 insertions(+), 29 deletions(-) create mode 100644 .maestro/scene_url_warm.yaml diff --git a/.maestro/run_scene_push.sh b/.maestro/run_scene_push.sh index 8a73ce17..4cba14b7 100755 --- a/.maestro/run_scene_push.sh +++ b/.maestro/run_scene_push.sh @@ -144,40 +144,44 @@ package_dir="$host_parent/package" derived_data="$host_parent/derived-data" mkdir -p "$package_dir" -run_notification_flow() { - local flow="$1" - local payload="$2" +# Starts a Maestro flow and runs the injection command only once the flow's output shows +# the milestone step completed, so the event reaches the simulator while the flow is +# already waiting for it. +run_flow_after_milestone() { + local flow_name="$1" + local milestone="$2" + shift 2 + local maestro_args=(--device "$device_id" test) local ready=false local status=0 - local flow_name="${flow##*/}" - local maestro_args=(--device "$device_id" test "$flow") - flow_name="${flow_name%.yaml}" if [[ -n "${RUNNER_TEMP:-}" ]]; then - maestro_args=( - --device "$device_id" - test + maestro_args+=( --debug-output "$RUNNER_TEMP/react-native-scene-maestro-$flow_name" --flatten-debug-output - "$flow" ) fi + while [[ "$1" != -- ]]; do + maestro_args+=("$1") + shift + done + shift flow_log="$(mktemp "${TMPDIR:-/tmp}/cio-rn-maestro-flow.XXXXXX")" maestro "${maestro_args[@]}" > >(tee "$flow_log") 2>&1 & flow_pid=$! for _ in {1..240}; do - if grep -q 'Press Home key.*COMPLETED' "$flow_log"; then + if grep -qF "$milestone" "$flow_log"; then ready=true break fi if ! kill -0 "$flow_pid" >/dev/null 2>&1; then if wait "$flow_pid"; then - echo "error: Maestro completed before reaching the Home screen" >&2 + echo "error: Maestro completed before '$milestone'" >&2 else status=$? - echo "error: Maestro exited before reaching the Home screen (status $status)" >&2 + echo "error: Maestro exited before '$milestone' (status $status)" >&2 fi flow_pid="" return 1 @@ -186,10 +190,22 @@ run_notification_flow() { done if [[ "$ready" != true ]]; then - echo "error: Maestro did not reach the Home screen before notification injection" >&2 + echo "error: Maestro did not reach '$milestone' before injection" >&2 return 1 fi + "$@" || return 1 + if ! wait "$flow_pid"; then + flow_pid="" + return 1 + fi + flow_pid="" + rm -f "$flow_log" + flow_log="" +} + +push_notification() { + local payload="$1" local push_output if ! push_output="$(xcrun simctl push "$device_id" "$APP_ID" "$payload" 2>&1)"; then printf '%s\n' "$push_output" >&2 @@ -201,18 +217,30 @@ run_notification_flow() { return 1 fi printf '%s\n' "$push_output" - if ! wait "$flow_pid"; then - flow_pid="" - return 1 - fi - flow_pid="" - rm -f "$flow_log" - flow_log="" } -run_ordinary_url_flow() { +run_notification_flow() { + local flow="$1" + local payload="$2" + local flow_name="${flow##*/}" + + run_flow_after_milestone "${flow_name%.yaml}" 'Press Home key... COMPLETED' \ + "$flow" -- push_notification "$payload" +} + +# A URL opened while the app is running gets SpringBoard's "Open in" prompt. Opening it +# before Maestro starts left that prompt up for 40-75s while Maestro relaunched its test +# runner, and the accepted open sometimes never reached the app. The warm flow opens the +# URL from inside the running flow instead, so the prompt is answered as soon as it shows. +run_warm_url_flow() { + local url="$1" + + run_flow_after_milestone scene_url_open-warm 'Assert that "Routing: acknowledged" is visible... COMPLETED' \ + -e "EXPECTED_URL=$url" .maestro/scene_url_warm.yaml -- xcrun simctl openurl "$device_id" "$url" +} + +run_cold_url_flow() { local url="$1" - local state="$2" local ordinary_args=( --device "$device_id" test @@ -225,7 +253,7 @@ run_ordinary_url_flow() { ordinary_args=( --device "$device_id" test - --debug-output "$RUNNER_TEMP/react-native-scene-maestro-scene_url_open-$state" + --debug-output "$RUNNER_TEMP/react-native-scene-maestro-scene_url_open-cold" --flatten-debug-output -e "EXPECTED_URL=$url" .maestro/scene_url_open.yaml @@ -319,11 +347,11 @@ for routing_mode in acknowledged linking; do if [[ "$routing_mode" == acknowledged ]]; then current_phase="ordinary-link-warm-$routing_mode" - run_ordinary_url_flow 'cio-rn-scene-e2e://ordinary-warm' warm + run_warm_url_flow 'cio-rn-scene-e2e://ordinary-warm' xcrun simctl terminate "$device_id" "$APP_ID" current_phase="ordinary-link-cold-$routing_mode" - run_ordinary_url_flow 'cio-rn-scene-e2e://ordinary-cold' cold + run_cold_url_flow 'cio-rn-scene-e2e://ordinary-cold' fi xcrun simctl terminate "$device_id" "$APP_ID" diff --git a/.maestro/scene_url_open.yaml b/.maestro/scene_url_open.yaml index df0bdfdb..52938791 100644 --- a/.maestro/scene_url_open.yaml +++ b/.maestro/scene_url_open.yaml @@ -1,9 +1,6 @@ appId: org.reactjs.native.example.CioRnSceneHost name: React Native UIScene ordinary URL --- -- tapOn: - text: Open - optional: true - extendedWaitUntil: visible: 'Customer.io React Native scene E2E ready' timeout: 60000 diff --git a/.maestro/scene_url_warm.yaml b/.maestro/scene_url_warm.yaml new file mode 100644 index 00000000..86290f9e --- /dev/null +++ b/.maestro/scene_url_warm.yaml @@ -0,0 +1,16 @@ +appId: org.reactjs.native.example.CioRnSceneHost +name: React Native UIScene ordinary URL, warm +--- +# run_scene_push.sh opens EXPECTED_URL only after the Routing assertion completes, so the +# app is still in front and SpringBoard's "Open in" prompt is answered as soon as it appears. +- extendedWaitUntil: + visible: 'Customer.io React Native scene E2E ready' + timeout: 60000 +- assertVisible: 'Routing: acknowledged' +- extendedWaitUntil: + visible: 'Open' + timeout: 60000 +- tapOn: 'Open' +- extendedWaitUntil: + visible: 'Received: ${EXPECTED_URL}' + timeout: 60000 From b0cb3162b5b120485cf43b782e820531d3a7649e Mon Sep 17 00:00:00 2001 From: Moby Date: Thu, 19 Nov 2026 18:16:50 +0000 Subject: [PATCH 04/10] MBL-2804: pre-approve the scene url scheme instead of tapping the open in prompt --- .maestro/run_scene_push.sh | 85 +++++++++++++----------------------- .maestro/scene_url_warm.yaml | 16 ------- 2 files changed, 31 insertions(+), 70 deletions(-) delete mode 100644 .maestro/scene_url_warm.yaml diff --git a/.maestro/run_scene_push.sh b/.maestro/run_scene_push.sh index 4cba14b7..600d89bc 100755 --- a/.maestro/run_scene_push.sh +++ b/.maestro/run_scene_push.sh @@ -144,44 +144,40 @@ package_dir="$host_parent/package" derived_data="$host_parent/derived-data" mkdir -p "$package_dir" -# Starts a Maestro flow and runs the injection command only once the flow's output shows -# the milestone step completed, so the event reaches the simulator while the flow is -# already waiting for it. -run_flow_after_milestone() { - local flow_name="$1" - local milestone="$2" - shift 2 - local maestro_args=(--device "$device_id" test) +run_notification_flow() { + local flow="$1" + local payload="$2" local ready=false local status=0 + local flow_name="${flow##*/}" + local maestro_args=(--device "$device_id" test "$flow") + flow_name="${flow_name%.yaml}" if [[ -n "${RUNNER_TEMP:-}" ]]; then - maestro_args+=( + maestro_args=( + --device "$device_id" + test --debug-output "$RUNNER_TEMP/react-native-scene-maestro-$flow_name" --flatten-debug-output + "$flow" ) fi - while [[ "$1" != -- ]]; do - maestro_args+=("$1") - shift - done - shift flow_log="$(mktemp "${TMPDIR:-/tmp}/cio-rn-maestro-flow.XXXXXX")" maestro "${maestro_args[@]}" > >(tee "$flow_log") 2>&1 & flow_pid=$! for _ in {1..240}; do - if grep -qF "$milestone" "$flow_log"; then + if grep -q 'Press Home key.*COMPLETED' "$flow_log"; then ready=true break fi if ! kill -0 "$flow_pid" >/dev/null 2>&1; then if wait "$flow_pid"; then - echo "error: Maestro completed before '$milestone'" >&2 + echo "error: Maestro completed before reaching the Home screen" >&2 else status=$? - echo "error: Maestro exited before '$milestone' (status $status)" >&2 + echo "error: Maestro exited before reaching the Home screen (status $status)" >&2 fi flow_pid="" return 1 @@ -190,22 +186,10 @@ run_flow_after_milestone() { done if [[ "$ready" != true ]]; then - echo "error: Maestro did not reach '$milestone' before injection" >&2 + echo "error: Maestro did not reach the Home screen before notification injection" >&2 return 1 fi - "$@" || return 1 - if ! wait "$flow_pid"; then - flow_pid="" - return 1 - fi - flow_pid="" - rm -f "$flow_log" - flow_log="" -} - -push_notification() { - local payload="$1" local push_output if ! push_output="$(xcrun simctl push "$device_id" "$APP_ID" "$payload" 2>&1)"; then printf '%s\n' "$push_output" >&2 @@ -217,30 +201,18 @@ push_notification() { return 1 fi printf '%s\n' "$push_output" + if ! wait "$flow_pid"; then + flow_pid="" + return 1 + fi + flow_pid="" + rm -f "$flow_log" + flow_log="" } -run_notification_flow() { - local flow="$1" - local payload="$2" - local flow_name="${flow##*/}" - - run_flow_after_milestone "${flow_name%.yaml}" 'Press Home key... COMPLETED' \ - "$flow" -- push_notification "$payload" -} - -# A URL opened while the app is running gets SpringBoard's "Open in" prompt. Opening it -# before Maestro starts left that prompt up for 40-75s while Maestro relaunched its test -# runner, and the accepted open sometimes never reached the app. The warm flow opens the -# URL from inside the running flow instead, so the prompt is answered as soon as it shows. -run_warm_url_flow() { - local url="$1" - - run_flow_after_milestone scene_url_open-warm 'Assert that "Routing: acknowledged" is visible... COMPLETED' \ - -e "EXPECTED_URL=$url" .maestro/scene_url_warm.yaml -- xcrun simctl openurl "$device_id" "$url" -} - -run_cold_url_flow() { +run_ordinary_url_flow() { local url="$1" + local state="$2" local ordinary_args=( --device "$device_id" test @@ -253,7 +225,7 @@ run_cold_url_flow() { ordinary_args=( --device "$device_id" test - --debug-output "$RUNNER_TEMP/react-native-scene-maestro-scene_url_open-cold" + --debug-output "$RUNNER_TEMP/react-native-scene-maestro-scene_url_open-$state" --flatten-debug-output -e "EXPECTED_URL=$url" .maestro/scene_url_open.yaml @@ -328,6 +300,11 @@ test -d "$app_path" xcrun simctl uninstall "$device_id" "$APP_ID" >/dev/null 2>&1 || true xcrun simctl install "$device_id" "$app_path" installed_app=true +# Approve the URL scheme for simctl openurl, as tapping Open once on SpringBoard's +# "Open in" prompt would. Without it the first open of the warm URL waits on that prompt, +# and the open accepted there sometimes never reached the app. +xcrun simctl spawn "$device_id" defaults write com.apple.launchservices.schemeapproval \ + 'com.apple.CoreSimulator.CoreSimulatorBridge-->cio-rn-scene-e2e' -string "$APP_ID" cd "$REPO_ROOT" for routing_mode in acknowledged linking; do @@ -347,11 +324,11 @@ for routing_mode in acknowledged linking; do if [[ "$routing_mode" == acknowledged ]]; then current_phase="ordinary-link-warm-$routing_mode" - run_warm_url_flow 'cio-rn-scene-e2e://ordinary-warm' + run_ordinary_url_flow 'cio-rn-scene-e2e://ordinary-warm' warm xcrun simctl terminate "$device_id" "$APP_ID" current_phase="ordinary-link-cold-$routing_mode" - run_cold_url_flow 'cio-rn-scene-e2e://ordinary-cold' + run_ordinary_url_flow 'cio-rn-scene-e2e://ordinary-cold' cold fi xcrun simctl terminate "$device_id" "$APP_ID" diff --git a/.maestro/scene_url_warm.yaml b/.maestro/scene_url_warm.yaml deleted file mode 100644 index 86290f9e..00000000 --- a/.maestro/scene_url_warm.yaml +++ /dev/null @@ -1,16 +0,0 @@ -appId: org.reactjs.native.example.CioRnSceneHost -name: React Native UIScene ordinary URL, warm ---- -# run_scene_push.sh opens EXPECTED_URL only after the Routing assertion completes, so the -# app is still in front and SpringBoard's "Open in" prompt is answered as soon as it appears. -- extendedWaitUntil: - visible: 'Customer.io React Native scene E2E ready' - timeout: 60000 -- assertVisible: 'Routing: acknowledged' -- extendedWaitUntil: - visible: 'Open' - timeout: 60000 -- tapOn: 'Open' -- extendedWaitUntil: - visible: 'Received: ${EXPECTED_URL}' - timeout: 60000 From 73044ad88e47f917137c35119d3e5fc5b2508067 Mon Sep 17 00:00:00 2001 From: Moby Date: Thu, 19 Nov 2026 21:07:45 +0000 Subject: [PATCH 05/10] MBL-2804: point the scheme approval comment at expo, name the app install phase, and drop the url received wait --- .maestro/run_scene_push.sh | 6 +++--- .maestro/scene_url_open.yaml | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.maestro/run_scene_push.sh b/.maestro/run_scene_push.sh index 600d89bc..053934db 100755 --- a/.maestro/run_scene_push.sh +++ b/.maestro/run_scene_push.sh @@ -297,12 +297,12 @@ xcodebuild -quiet \ app_path="$derived_data/Build/Products/Release-iphonesimulator/$APP_NAME.app" test -d "$app_path" +current_phase="app-install" xcrun simctl uninstall "$device_id" "$APP_ID" >/dev/null 2>&1 || true xcrun simctl install "$device_id" "$app_path" installed_app=true -# Approve the URL scheme for simctl openurl, as tapping Open once on SpringBoard's -# "Open in" prompt would. Without it the first open of the warm URL waits on that prompt, -# and the open accepted there sometimes never reached the app. +# Pre-approve the URL scheme so simctl openurl never shows SpringBoard's "Open in" prompt, +# like preApproveDeepLinkPromptAsync in Expo's apps/bare-expo/scripts/start-ios-e2e-test.ts. xcrun simctl spawn "$device_id" defaults write com.apple.launchservices.schemeapproval \ 'com.apple.CoreSimulator.CoreSimulatorBridge-->cio-rn-scene-e2e' -string "$APP_ID" diff --git a/.maestro/scene_url_open.yaml b/.maestro/scene_url_open.yaml index 52938791..050d6c7b 100644 --- a/.maestro/scene_url_open.yaml +++ b/.maestro/scene_url_open.yaml @@ -5,6 +5,4 @@ name: React Native UIScene ordinary URL visible: 'Customer.io React Native scene E2E ready' timeout: 60000 - assertVisible: 'Routing: acknowledged' -- extendedWaitUntil: - visible: 'Received: ${EXPECTED_URL}' - timeout: 60000 +- assertVisible: 'Received: ${EXPECTED_URL}' From 0127a51149478191c59642d27a4b209fe76fd027 Mon Sep 17 00:00:00 2001 From: Moby Date: Thu, 19 Nov 2026 22:15:15 +0000 Subject: [PATCH 06/10] MBL-2804: make the scene host's notification banners persistent so the banner tap has no deadline --- .maestro/README.md | 6 + .maestro/run_scene_push.sh | 19 ++- .maestro/set_persistent_banners.py | 180 +++++++++++++++++++++++++++++ 3 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 .maestro/set_persistent_banners.py diff --git a/.maestro/README.md b/.maestro/README.md index 3484a8f2..f36a9ea1 100644 --- a/.maestro/README.md +++ b/.maestro/README.md @@ -26,3 +26,9 @@ The script uses `E2E_DEVICE_ID` or `E2E_SIMULATOR_NAME` when set. Otherwise it takes a booted iPhone on the iOS runtime named by `E2E_IOS_RUNTIME_MAJOR` (default 27), then the newest numbered iPhone Pro on that runtime, then any iPhone, so CI keeps working when runner images rename their simulators. + +After installing the host, the script shuts the simulator down, allows the +host's notifications with the Persistent banner style +(`set_persistent_banners.py`), and boots it again. A temporary banner leaves +the screen about six seconds after it appears, so a slow tap would miss it; a +persistent banner waits for the tap. diff --git a/.maestro/run_scene_push.sh b/.maestro/run_scene_push.sh index 053934db..d6ae47c6 100755 --- a/.maestro/run_scene_push.sh +++ b/.maestro/run_scene_push.sh @@ -18,7 +18,7 @@ fi export DEVELOPER_DIR export MAESTRO_CLI_NO_ANALYTICS=1 -for command in bundle jq maestro node npm npx ruby xcodebuild xcrun; do +for command in bundle jq maestro node npm npx python3 ruby xcodebuild xcrun; do command -v "$command" >/dev/null 2>&1 || { echo "error: required command '$command' is not installed" >&2 exit 2 @@ -301,6 +301,21 @@ current_phase="app-install" xcrun simctl uninstall "$device_id" "$APP_ID" >/dev/null 2>&1 || true xcrun simctl install "$device_id" "$app_path" installed_app=true + +# iOS revokes a temporary banner about six seconds after it appears, so a slow banner tap +# found the Home screen instead. Allow the app's notifications with the Persistent banner +# style, which stays until tapped. SpringBoard rewrites this file from memory while it +# runs, so the record is written with the simulator shut down. +current_phase="notification-settings" +section_store="$(xcrun simctl list devices -j | jq -r --arg id "$device_id" \ + '[.devices[][] | select(.udid == $id)][0].dataPath')/Library/BulletinBoard/VersionedSectionInfo.plist" +notification_settings_log="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/react-native-scene-maestro-notification-settings.log" +xcrun simctl shutdown "$device_id" +python3 "$REPO_ROOT/.maestro/set_persistent_banners.py" "$section_store" "$APP_ID" "$APP_NAME" +python3 "$REPO_ROOT/.maestro/set_persistent_banners.py" --check "$section_store" "$APP_ID" \ + | sed 's/^/written: /' | tee "$notification_settings_log" +xcrun simctl boot "$device_id" +xcrun simctl bootstatus "$device_id" -b # Pre-approve the URL scheme so simctl openurl never shows SpringBoard's "Open in" prompt, # like preApproveDeepLinkPromptAsync in Expo's apps/bare-expo/scripts/start-ios-e2e-test.ts. xcrun simctl spawn "$device_id" defaults write com.apple.launchservices.schemeapproval \ @@ -321,6 +336,8 @@ for routing_mode in acknowledged linking; do ) fi maestro "${prepare_args[@]}" + python3 .maestro/set_persistent_banners.py --check "$section_store" "$APP_ID" \ + | sed "s/^/after prepare-$routing_mode: /" | tee -a "$notification_settings_log" if [[ "$routing_mode" == acknowledged ]]; then current_phase="ordinary-link-warm-$routing_mode" diff --git a/.maestro/set_persistent_banners.py b/.maestro/set_persistent_banners.py new file mode 100644 index 00000000..1ccccfda --- /dev/null +++ b/.maestro/set_persistent_banners.py @@ -0,0 +1,180 @@ +#!/usr/bin/env python3 +# The BBSectionInfo record below is adapted from set_notification_permission.py in +# https://github.com/imranbarbhuiya/ios-sim-notification-permission +# under its MIT License: +# +# Copyright (c) 2026 imranbarbhuiya +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +"""Writes a simulator notification record that makes an app's banners persistent. + + set_persistent_banners.py + set_persistent_banners.py --check + +iOS removes a temporary banner about six seconds after it appears, so a test tap that +lands later finds the Home screen instead. A persistent banner stays until it is tapped. +iOS keeps the setting in data/Library/BulletinBoard/VersionedSectionInfo.plist as one +NSKeyedArchiver-encoded BBSectionInfo per bundle id. This writes the record iOS 27.2 +saves after a user allows notifications, with alertType 2 (Alert, which Settings shows +as the Persistent banner style) instead of 1 (Banner, the Temporary style). +applesimutils edits the same file for its notifications permission. + +SpringBoard rewrites the file from memory, so run_scene_push.sh writes it while the +simulator is shut down. --check decodes the saved record and fails unless it is still +authorized with the persistent style, so a run shows whether SpringBoard kept it. +""" + +import os +import plistlib +import sys +import time +from plistlib import UID + +AUTHORIZED = 2 +PERSISTENT_ALERT_TYPE = 2 +# Seconds between the Cocoa reference date (2001-01-01) and the Unix epoch. +COCOA_EPOCH = 978307200 + + +def section_info(bundle_id: str, name: str) -> bytes: + settings = { + "$class": UID(4), + "authorizationStatus": AUTHORIZED, + "authorizationExpirationDate": UID(0), + "lastUserGrantedAuthorizationDate": UID(0), + "alertType": PERSISTENT_ALERT_TYPE, + "pushSettings": 63, + "showsInNotificationCenter": True, + "showsInLockScreen": True, + "showsOnExternalDevices": True, + "notificationCenterSetting": 2, + "lockScreenSetting": 2, + "remoteNotificationsSetting": 2, + "carPlaySetting": 0, + "criticalAlertSetting": 0, + "timeSensitiveSetting": 0, + "userConfiguredTimeSensitiveSetting": False, + "directMessagesSettingKey": 0, + "userConfiguredDirectMessagesSetting": False, + "announceSetting": 1, + "announcePriority": 0, + "bulletinGroupingSetting": 0, + "contentPreviewSetting": 0, + "prioritizationSetting": 2, + "summarizationSetting": 2, + "scheduledDeliverySetting": 1, + "showsCustomSettingsLink": False, + "muteAssertion": UID(0), + } + info = { + "$class": UID(10), + "sectionID": UID(2), + "sectionInfoSettings": UID(3), + "lastSettingChangeDate": UID(5), + "appName": UID(7), + "displayName": UID(8), + "version": UID(9), + "lastSettingSource": 2, + "sectionType": 0, + "sectionCategory": 0, + "subsectionPriority": 0, + "suppressFromSettings": False, + "suppressedSettings": 0, + "isRestricted": False, + "isModificationAllowed": False, + "hasEverBeenUserChanged": False, + "isAppClip": False, + "isLocked": False, + "hideWeeApp": False, + "customSettingsBundle": UID(0), + "customSettingsDetailControllerClass": UID(0), + "icon": UID(0), + "subsections": UID(0), + "subsectionID": UID(0), + "managedSectionInfoSettings": UID(0), + "factorySectionID": UID(0), + "dataProviderIDs": UID(0), + "pathToWeeAppPluginBundle": UID(0), + } + objects = [ + "$null", + info, + bundle_id, + settings, + {"$classname": "BBSectionInfoSettings", "$classes": ["BBSectionInfoSettings", "NSObject"]}, + {"NS.time": time.time() - COCOA_EPOCH, "$class": UID(6)}, + {"$classname": "NSDate", "$classes": ["NSDate", "NSObject"]}, + name, + name, + 0, + {"$classname": "BBSectionInfo", "$classes": ["BBSectionInfo", "NSObject"]}, + ] + archive = { + "$version": 100000, + "$archiver": "NSKeyedArchiver", + "$top": {"root": UID(1)}, + "$objects": objects, + } + return plistlib.dumps(archive, fmt=plistlib.FMT_BINARY) + + +def check(sections: dict, bundle_id: str) -> int: + record = sections.get(bundle_id) + if not isinstance(record, bytes): + print(f"error: no notification record for {bundle_id}", file=sys.stderr) + return 1 + archive = plistlib.loads(record) + objects = archive["$objects"] + info = objects[archive["$top"]["root"]] + settings = objects[info["sectionInfoSettings"]] + alert_type = settings.get("alertType") + status = settings.get("authorizationStatus") + print(f"{bundle_id} notification record: alertType={alert_type} authorizationStatus={status}") + if alert_type != PERSISTENT_ALERT_TYPE or status != AUTHORIZED: + print("error: notification banners are not persistent; a late banner tap would miss", file=sys.stderr) + return 1 + return 0 + + +def main() -> int: + args = sys.argv[1:] + checking = args[:1] == ["--check"] + if len(args) != 3: + print(__doc__.strip(), file=sys.stderr) + return 2 + if checking: + args = args[1:] + path, bundle_id = args[0], args[1] + with open(path, "rb") as handle: + store = plistlib.load(handle) + sections = store.get("sectionInfo") + if not isinstance(sections, dict): + print(f"error: {path} has no sectionInfo dictionary", file=sys.stderr) + return 1 + if checking: + return check(sections, bundle_id) + sections[bundle_id] = section_info(bundle_id, args[2]) + with open(path + ".tmp", "wb") as handle: + plistlib.dump(store, handle, fmt=plistlib.FMT_BINARY) + os.replace(path + ".tmp", path) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) From 3924ee3116aa28ba92d5a451c654b96a664eac95 Mon Sep 17 00:00:00 2001 From: Moby Date: Fri, 20 Nov 2026 00:21:34 +0000 Subject: [PATCH 07/10] MBL-2804: write the persistent banner record with springboard stopped instead of rebooting the simulator --- .maestro/README.md | 10 +++++----- .maestro/run_scene_push.sh | 13 ++++++++----- .maestro/set_persistent_banners.py | 7 ++++--- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.maestro/README.md b/.maestro/README.md index f36a9ea1..8ce9d499 100644 --- a/.maestro/README.md +++ b/.maestro/README.md @@ -27,8 +27,8 @@ takes a booted iPhone on the iOS runtime named by `E2E_IOS_RUNTIME_MAJOR` (default 27), then the newest numbered iPhone Pro on that runtime, then any iPhone, so CI keeps working when runner images rename their simulators. -After installing the host, the script shuts the simulator down, allows the -host's notifications with the Persistent banner style -(`set_persistent_banners.py`), and boots it again. A temporary banner leaves -the screen about six seconds after it appears, so a slow tap would miss it; a -persistent banner waits for the tap. +After installing the host, the script stops SpringBoard, allows the host's +notifications with the Persistent banner style (`set_persistent_banners.py`), +and starts SpringBoard again. A temporary banner leaves the screen about six +seconds after it appears, so a slow tap would miss it; a persistent banner +waits for the tap. diff --git a/.maestro/run_scene_push.sh b/.maestro/run_scene_push.sh index d6ae47c6..5df5bfc0 100755 --- a/.maestro/run_scene_push.sh +++ b/.maestro/run_scene_push.sh @@ -304,18 +304,21 @@ installed_app=true # iOS revokes a temporary banner about six seconds after it appears, so a slow banner tap # found the Home screen instead. Allow the app's notifications with the Persistent banner -# style, which stays until tapped. SpringBoard rewrites this file from memory while it -# runs, so the record is written with the simulator shut down. +# style, which stays until tapped. SpringBoard keeps this file in memory and rewrites it as +# it stops, so it is stopped before the write and started after (as ios-sim-notification-permission does). current_phase="notification-settings" section_store="$(xcrun simctl list devices -j | jq -r --arg id "$device_id" \ '[.devices[][] | select(.udid == $id)][0].dataPath')/Library/BulletinBoard/VersionedSectionInfo.plist" notification_settings_log="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/react-native-scene-maestro-notification-settings.log" -xcrun simctl shutdown "$device_id" +for service in com.apple.SpringBoard com.apple.usernotificationsd; do + xcrun simctl spawn "$device_id" launchctl stop "$service" +done python3 "$REPO_ROOT/.maestro/set_persistent_banners.py" "$section_store" "$APP_ID" "$APP_NAME" +for service in com.apple.SpringBoard com.apple.usernotificationsd; do + xcrun simctl spawn "$device_id" launchctl start "$service" +done python3 "$REPO_ROOT/.maestro/set_persistent_banners.py" --check "$section_store" "$APP_ID" \ | sed 's/^/written: /' | tee "$notification_settings_log" -xcrun simctl boot "$device_id" -xcrun simctl bootstatus "$device_id" -b # Pre-approve the URL scheme so simctl openurl never shows SpringBoard's "Open in" prompt, # like preApproveDeepLinkPromptAsync in Expo's apps/bare-expo/scripts/start-ios-e2e-test.ts. xcrun simctl spawn "$device_id" defaults write com.apple.launchservices.schemeapproval \ diff --git a/.maestro/set_persistent_banners.py b/.maestro/set_persistent_banners.py index 1ccccfda..68da46d1 100644 --- a/.maestro/set_persistent_banners.py +++ b/.maestro/set_persistent_banners.py @@ -35,9 +35,10 @@ as the Persistent banner style) instead of 1 (Banner, the Temporary style). applesimutils edits the same file for its notifications permission. -SpringBoard rewrites the file from memory, so run_scene_push.sh writes it while the -simulator is shut down. --check decodes the saved record and fails unless it is still -authorized with the persistent style, so a run shows whether SpringBoard kept it. +SpringBoard rewrites the file from memory as it stops, so run_scene_push.sh stops it and +usernotificationsd before the write and starts them after. --check decodes the saved +record and fails unless it is still authorized with the persistent style, so a run shows +whether SpringBoard kept it. """ import os From 70c6cf41be71c27dc0d62fda50ae1ec896e3da0a Mon Sep 17 00:00:00 2001 From: Moby Date: Fri, 20 Nov 2026 01:45:57 +0000 Subject: [PATCH 08/10] MBL-2804: gate on the post-prepare banner check, label its failure phase, and keep one explanation of the persistent banner write --- .maestro/README.md | 6 ------ .maestro/run_scene_push.sh | 10 +++++----- .maestro/set_persistent_banners.py | 5 +++-- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/.maestro/README.md b/.maestro/README.md index 8ce9d499..3484a8f2 100644 --- a/.maestro/README.md +++ b/.maestro/README.md @@ -26,9 +26,3 @@ The script uses `E2E_DEVICE_ID` or `E2E_SIMULATOR_NAME` when set. Otherwise it takes a booted iPhone on the iOS runtime named by `E2E_IOS_RUNTIME_MAJOR` (default 27), then the newest numbered iPhone Pro on that runtime, then any iPhone, so CI keeps working when runner images rename their simulators. - -After installing the host, the script stops SpringBoard, allows the host's -notifications with the Persistent banner style (`set_persistent_banners.py`), -and starts SpringBoard again. A temporary banner leaves the screen about six -seconds after it appears, so a slow tap would miss it; a persistent banner -waits for the tap. diff --git a/.maestro/run_scene_push.sh b/.maestro/run_scene_push.sh index 5df5bfc0..cf5a7868 100755 --- a/.maestro/run_scene_push.sh +++ b/.maestro/run_scene_push.sh @@ -302,10 +302,7 @@ xcrun simctl uninstall "$device_id" "$APP_ID" >/dev/null 2>&1 || true xcrun simctl install "$device_id" "$app_path" installed_app=true -# iOS revokes a temporary banner about six seconds after it appears, so a slow banner tap -# found the Home screen instead. Allow the app's notifications with the Persistent banner -# style, which stays until tapped. SpringBoard keeps this file in memory and rewrites it as -# it stops, so it is stopped before the write and started after (as ios-sim-notification-permission does). +# Persistent notification banners, so a slow tap still finds the banner; why and how in set_persistent_banners.py. current_phase="notification-settings" section_store="$(xcrun simctl list devices -j | jq -r --arg id "$device_id" \ '[.devices[][] | select(.udid == $id)][0].dataPath')/Library/BulletinBoard/VersionedSectionInfo.plist" @@ -317,8 +314,10 @@ python3 "$REPO_ROOT/.maestro/set_persistent_banners.py" "$section_store" "$APP_I for service in com.apple.SpringBoard com.apple.usernotificationsd; do xcrun simctl spawn "$device_id" launchctl start "$service" done +# Right after the write this reads back our own write, so it is a log baseline, not proof +# SpringBoard kept the record. The check after each prepare flow is the gate. python3 "$REPO_ROOT/.maestro/set_persistent_banners.py" --check "$section_store" "$APP_ID" \ - | sed 's/^/written: /' | tee "$notification_settings_log" + | sed 's/^/after write: /' | tee "$notification_settings_log" # Pre-approve the URL scheme so simctl openurl never shows SpringBoard's "Open in" prompt, # like preApproveDeepLinkPromptAsync in Expo's apps/bare-expo/scripts/start-ios-e2e-test.ts. xcrun simctl spawn "$device_id" defaults write com.apple.launchservices.schemeapproval \ @@ -339,6 +338,7 @@ for routing_mode in acknowledged linking; do ) fi maestro "${prepare_args[@]}" + current_phase="notification-settings-$routing_mode" python3 .maestro/set_persistent_banners.py --check "$section_store" "$APP_ID" \ | sed "s/^/after prepare-$routing_mode: /" | tee -a "$notification_settings_log" diff --git a/.maestro/set_persistent_banners.py b/.maestro/set_persistent_banners.py index 68da46d1..79841fd8 100644 --- a/.maestro/set_persistent_banners.py +++ b/.maestro/set_persistent_banners.py @@ -33,12 +33,13 @@ NSKeyedArchiver-encoded BBSectionInfo per bundle id. This writes the record iOS 27.2 saves after a user allows notifications, with alertType 2 (Alert, which Settings shows as the Persistent banner style) instead of 1 (Banner, the Temporary style). -applesimutils edits the same file for its notifications permission. SpringBoard rewrites the file from memory as it stops, so run_scene_push.sh stops it and usernotificationsd before the write and starts them after. --check decodes the saved record and fails unless it is still authorized with the persistent style, so a run shows -whether SpringBoard kept it. +whether SpringBoard kept it. --check reads the file on disk, not SpringBoard's memory: an +iOS release that ignores alertType would still pass it and bring the late-tap failure +back. The live signal is `alertStyle: Alert` for the app in the simulator's device log. """ import os From e5978f155c845d6bdab27ec2d18ffb748cce289c Mon Sep 17 00:00:00 2001 From: Moby Date: Fri, 20 Nov 2026 02:35:07 +0000 Subject: [PATCH 09/10] MBL-2804: cut scene harness time: build only the simulator's architecture, boot the simulator during the build, install host packages once, and mark phase boundaries --- .maestro/run_scene_push.sh | 49 ++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/.maestro/run_scene_push.sh b/.maestro/run_scene_push.sh index cf5a7868..ecb35ab1 100755 --- a/.maestro/run_scene_push.sh +++ b/.maestro/run_scene_push.sh @@ -77,8 +77,14 @@ package_dir="" derived_data="" flow_log="" flow_pid="" +boot_pid="" installed_app=false current_phase="setup" +# Phase markers give the step log's timestamps a boundary for every phase. +enter_phase() { + current_phase="$1" + echo "==> phase: $current_phase" +} cleanup() { local exit_code=$? set +e @@ -98,6 +104,10 @@ cleanup() { if [[ -n "$flow_log" ]]; then rm -f "$flow_log" fi + if [[ -n "$boot_pid" ]]; then + kill "$boot_pid" >/dev/null 2>&1 || true + wait "$boot_pid" 2>/dev/null || true + fi if [[ "$installed_app" == true ]]; then xcrun simctl terminate "$device_id" "$APP_ID" >/dev/null 2>&1 || true xcrun simctl uninstall "$device_id" "$APP_ID" >/dev/null 2>&1 || true @@ -128,10 +138,12 @@ trap cleanup EXIT if ! jq -e --arg id "$device_id" \ 'any(.devices[][]; .udid == $id and .state == "Booted")' <<< "$simulator_devices" >/dev/null; then - xcrun simctl boot "$device_id" + # Boot in the background so it overlaps the package, pods and compile phases, none of which + # need the simulator; the app-install phase waits for it. + xcrun simctl boot "$device_id" & + boot_pid=$! simulator_started_by_runner=true fi -xcrun simctl bootstatus "$device_id" -b if [[ -n "${CIO_E2E_HOST_PARENT:-}" ]]; then host_parent="$CIO_E2E_HOST_PARENT" @@ -235,12 +247,12 @@ run_ordinary_url_flow() { } cd "$REPO_ROOT" -current_phase="package" +enter_phase package npm ci package_name="$(npm pack --silent --pack-destination "$package_dir" | tail -n 1)" cd "$host_parent" -current_phase="generate" +enter_phase generate npx "@react-native-community/cli@$RN_CLI_VERSION" init "$APP_NAME" \ --version "$RN_VERSION" \ --template "@react-native-community/template@$RN_TEMPLATE_VERSION" \ @@ -257,8 +269,7 @@ npm pkg set \ "devDependencies.@react-native/metro-config=$RN_VERSION" \ "devDependencies.@react-native/typescript-config=$RN_VERSION" \ "devDependencies.react-test-renderer=$REACT_VERSION" -current_phase="install" -npm install +enter_phase install npm install "$package_dir/$package_name" cp "$FIXTURE_DIR/App.tsx" App.tsx @@ -279,31 +290,39 @@ plist="ios/$APP_NAME/Info.plist" /usr/libexec/PlistBuddy -c 'Add :CFBundleURLTypes:0:CFBundleURLSchemes array' "$plist" /usr/libexec/PlistBuddy -c 'Add :CFBundleURLTypes:0:CFBundleURLSchemes:0 string cio-rn-scene-e2e' "$plist" -current_phase="pods" +enter_phase pods bundle install bundle exec ruby "$FIXTURE_DIR/configure_podfile.rb" ios/Podfile bundle exec ruby "$FIXTURE_DIR/configure.rb" "ios/$APP_NAME.xcodeproj" "$APP_NAME" bundle exec pod install --project-directory=ios -current_phase="compile" +enter_phase compile +# Release builds every simulator architecture by default; the test only runs the destination's. xcodebuild -quiet \ -workspace "ios/$APP_NAME.xcworkspace" \ -scheme "$APP_NAME" \ -configuration Release \ -destination "platform=iOS Simulator,id=$device_id" \ -derivedDataPath "$derived_data" \ + ONLY_ACTIVE_ARCH=YES \ CODE_SIGNING_ALLOWED=NO \ build app_path="$derived_data/Build/Products/Release-iphonesimulator/$APP_NAME.app" test -d "$app_path" -current_phase="app-install" +enter_phase boot +if [[ -n "$boot_pid" ]]; then + wait "$boot_pid" + boot_pid="" +fi +xcrun simctl bootstatus "$device_id" -b +enter_phase app-install xcrun simctl uninstall "$device_id" "$APP_ID" >/dev/null 2>&1 || true xcrun simctl install "$device_id" "$app_path" installed_app=true # Persistent notification banners, so a slow tap still finds the banner; why and how in set_persistent_banners.py. -current_phase="notification-settings" +enter_phase notification-settings section_store="$(xcrun simctl list devices -j | jq -r --arg id "$device_id" \ '[.devices[][] | select(.udid == $id)][0].dataPath')/Library/BulletinBoard/VersionedSectionInfo.plist" notification_settings_log="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/react-native-scene-maestro-notification-settings.log" @@ -325,7 +344,7 @@ xcrun simctl spawn "$device_id" defaults write com.apple.launchservices.schemeap cd "$REPO_ROOT" for routing_mode in acknowledged linking; do - current_phase="prepare-$routing_mode" + enter_phase "prepare-$routing_mode" prepare_args=(--device "$device_id" test -e "ROUTING_MODE=$routing_mode" .maestro/scene_push_prepare.yaml) if [[ -n "${RUNNER_TEMP:-}" ]]; then prepare_args=( @@ -338,21 +357,21 @@ for routing_mode in acknowledged linking; do ) fi maestro "${prepare_args[@]}" - current_phase="notification-settings-$routing_mode" + enter_phase "notification-settings-$routing_mode" python3 .maestro/set_persistent_banners.py --check "$section_store" "$APP_ID" \ | sed "s/^/after prepare-$routing_mode: /" | tee -a "$notification_settings_log" if [[ "$routing_mode" == acknowledged ]]; then - current_phase="ordinary-link-warm-$routing_mode" + enter_phase "ordinary-link-warm-$routing_mode" run_ordinary_url_flow 'cio-rn-scene-e2e://ordinary-warm' warm xcrun simctl terminate "$device_id" "$APP_ID" - current_phase="ordinary-link-cold-$routing_mode" + enter_phase "ordinary-link-cold-$routing_mode" run_ordinary_url_flow 'cio-rn-scene-e2e://ordinary-cold' cold fi xcrun simctl terminate "$device_id" "$APP_ID" - current_phase="routing-$routing_mode" + enter_phase "routing-$routing_mode" run_notification_flow .maestro/scene_push_open.yaml .maestro/fixtures/customerio_scene_cold.apns run_notification_flow .maestro/scene_push_warm.yaml .maestro/fixtures/customerio_scene_warm.apns if [[ "$routing_mode" == acknowledged ]]; then From 51af08761a8fcb0fdf64dcbf18e3c2379fca3774 Mon Sep 17 00:00:00 2001 From: Matt Frizzell Date: Fri, 20 Nov 2026 03:52:08 +0000 Subject: [PATCH 10/10] MBL-2804: name a background simulator boot failure where the script stops --- .maestro/run_scene_push.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.maestro/run_scene_push.sh b/.maestro/run_scene_push.sh index ecb35ab1..d42a2a58 100755 --- a/.maestro/run_scene_push.sh +++ b/.maestro/run_scene_push.sh @@ -80,7 +80,6 @@ flow_pid="" boot_pid="" installed_app=false current_phase="setup" -# Phase markers give the step log's timestamps a boundary for every phase. enter_phase() { current_phase="$1" echo "==> phase: $current_phase" @@ -142,6 +141,7 @@ if ! jq -e --arg id "$device_id" \ # need the simulator; the app-install phase waits for it. xcrun simctl boot "$device_id" & boot_pid=$! + echo "Booting $device_id in the background (pid $boot_pid)" simulator_started_by_runner=true fi @@ -312,7 +312,13 @@ app_path="$derived_data/Build/Products/Release-iphonesimulator/$APP_NAME.app" test -d "$app_path" enter_phase boot if [[ -n "$boot_pid" ]]; then - wait "$boot_pid" + if wait "$boot_pid"; then + : + else + status=$? + echo "error: simctl boot failed (status $status)" >&2 + exit "$status" + fi boot_pid="" fi xcrun simctl bootstatus "$device_id" -b