mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
705c6f57d6
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/33674 ## Issue In D35317070 (https://github.com/facebook/react-native/commit/0480f56c5b5478b6ebe5ad88e347cad2810bfb17) we introduced a way to configuring the Xcode environment via he `.xcode.env`, falling back to the old `find-node-for-xcode.sh` behavior in case of a misconfiguration. Unfortunately, there were an issue with the new architecture for which the pods were not able to locate the `find-node-for-xcode.sh`, crashing while building the new architecture. ## Solution This Diff solves the issue in two steps: 1. it exposes to the project the REACT_NATIVE_PATH like Android does here: D35451821 (https://github.com/facebook/react-native/commit/f8d7e0a968ea12606fd8cce03470fd374f732aad) 2. it leverages this new variables to reach the script ## Changelog [iOS][Changed] - Fixed the fallback behavior when the `.xcode.env` file is missing, actually using the old `find-node-for-xcode.sh` script Reviewed By: dmitryrykun Differential Revision: D35779165 fbshipit-source-id: 393ef9a0b98d32d9cf226f7d109fdefd772e5120
48 lines
1.7 KiB
Bash
Executable File
48 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
||
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||
#
|
||
# This source code is licensed under the MIT license found in the
|
||
# LICENSE file in the root directory of this source tree.
|
||
|
||
# This script is used to source in Xcode the environment settings required to run properly.
|
||
# The script first sources the base `.xcode.env` file.
|
||
# Then it sources the `.xcode.env.local` file if present, to override some local config
|
||
# Finally, it will execute the command passed i input if any.
|
||
#
|
||
# USAGE:
|
||
# ./with-environment.sh command
|
||
|
||
# Start with a default
|
||
NODE_BINARY=$(command -v node)
|
||
export NODE_BINARY
|
||
|
||
# Override the default with the global environment
|
||
ENV_PATH="$PODS_ROOT/../.xcode.env"
|
||
if [ -f "$ENV_PATH" ]; then
|
||
source "$ENV_PATH"
|
||
fi
|
||
|
||
# Override the global with the local environment
|
||
LOCAL_ENV_PATH="${ENV_PATH}.local"
|
||
if [ -f "$LOCAL_ENV_PATH" ]; then
|
||
source "$LOCAL_ENV_PATH"
|
||
fi
|
||
|
||
# Check whether NODE_BINARY has been properly set, otherwise help the users with a meaningful error.
|
||
if [ -n "$NODE_BINARY" ]; then
|
||
echo "Node found at: ${NODE_BINARY}"
|
||
else
|
||
echo "[Warning] You need to configure your node path in the `'.xcode.env' file` environment. " \
|
||
"You can set it up quickly by running: " \
|
||
"echo 'export NODE_BINARY=$(command -v node)' > .xcode.env " \
|
||
"in the ios folder. This is needed by React Native to work correctly. " \
|
||
"We fallback to the DEPRECATED behavior of finding `node`. This will be REMOVED in a future version. " \
|
||
"You can read more about this here: https://reactnative.dev/docs/environment-setup#optional-configuring-your-environment" >&2
|
||
source "${REACT_NATIVE_PATH}/scripts/find-node-for-xcode.sh"
|
||
fi
|
||
|
||
# Execute argument, if present
|
||
if [ -n "$1" ]; then
|
||
$1
|
||
fi
|