From f14207f9bd83c42b0841d6157676a0477bc0b3b3 Mon Sep 17 00:00:00 2001 From: Minh Vu Date: Wed, 27 May 2026 07:58:45 -0700 Subject: [PATCH] Fix codegen script phase error logging (#56956) Summary: This fixes the `error()` helper in `packages/react-native/scripts/react_native_pods_utils/script_phases.sh` so it logs messages instead of attempting to execute them as shell commands. The current implementation does: ```bash "[Codegen] $1" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1 ``` That causes the error path to fail with `command not found` under `set -e`, writes the shell error to `SCRIPT_OUTPUT_FILE_0` instead of the intended `[Codegen] ...` line, and truncates multi-part messages to `$1`. This change captures the full message with `$*`, prints it to stdout, and appends the formatted `[Codegen] ...` line to `SCRIPT_OUTPUT_FILE_0`. Fixes https://github.com/facebook/react-native/issues/56955. ## Changelog: [IOS] [FIXED] - Fix codegen script phase error logging in `script_phases.sh` Pull Request resolved: https://github.com/facebook/react-native/pull/56956 Test Plan: ```bash bash -n packages/react-native/scripts/react_native_pods_utils/script_phases.sh ``` ```bash bash -lc 'set +e; bash -lc '\''set -e; rm -f /tmp/rn-codegen-test.log; f(){ message="$*"; echo "$message"; echo "[Codegen] $message" >> /tmp/rn-codegen-test.log 2>&1; exit 1; }; f hello world'\''; status=$?; echo STATUS=$status; echo LOG_CONTENT_START; cat /tmp/rn-codegen-test.log 2>/dev/null; echo LOG_CONTENT_END' ``` Observed output: ```text hello world STATUS=1 LOG_CONTENT_START [Codegen] hello world LOG_CONTENT_END ``` Reviewed By: christophpurrer Differential Revision: D106401068 Pulled By: zeyap fbshipit-source-id: 1ca73c20d5b935f3451e4c48da171b6f6c22201f --- .../scripts/react_native_pods_utils/script_phases.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/react-native/scripts/react_native_pods_utils/script_phases.sh b/packages/react-native/scripts/react_native_pods_utils/script_phases.sh index 4606f35fbe6..05d7211dc86 100755 --- a/packages/react-native/scripts/react_native_pods_utils/script_phases.sh +++ b/packages/react-native/scripts/react_native_pods_utils/script_phases.sh @@ -16,8 +16,9 @@ cd "$RCT_SCRIPT_RN_DIR" CODEGEN_CLI_PATH="" error () { - echo "$1" - "[Codegen] $1" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1 + message="$*" + echo "$message" + echo "[Codegen] $message" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1 exit 1 }