-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce .xcode.env configuration file to source
node
(#33546)
Summary: Pull Request resolved: #33546 This Diff does 2 things: 1. Removes all the remnant of the `find-node.sh` script. This allows React Native to stay agnostic from any other node manager 2. Introduces a way for the developers to specify which `node` executable they want to use, through a simple `.env` file. ## Changelog [iOS][Changed] - This PR removes the `find-node.sh` scripts and replaces it with an `.xcode.env` file that is sourced by the script phases that needs it. The `.xcode.env` file is versioned: to customize a local environment, an unversioned `.xcode.local.env` can be used. Reviewed By: cortinico Differential Revision: D35317070 fbshipit-source-id: 4b400ba56aa2d574db563fa67b2008e1ddde1c59
- Loading branch information
1 parent
61b013e
commit 0480f56
Showing
13 changed files
with
86 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ DerivedData | |
*.ipa | ||
*.xcuserstate | ||
project.xcworkspace | ||
**/.xcode.env.local | ||
|
||
# Gradle | ||
/build/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This `.xcode.env` file is versioned and is used to source the environment | ||
# used when running script phases inside Xcode. | ||
# To customize your local environment, you can create an `.xcode.env.local` | ||
# file that is not versioned. | ||
|
||
# NODE_BINARY variable contains the PATH to the node executable. | ||
# | ||
# Customize the NODE_BINARY variable here. | ||
# For example, to use nvm with brew, add the following line | ||
# . "$(brew --prefix nvm)/nvm.sh" --no-use | ||
export NODE_BINARY=$(command -v node) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/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: <TODO-ADD LINK HERE>" >&2 | ||
source "../find-node-for-xcode.sh" | ||
fi | ||
|
||
# Execute argument, if present | ||
if [ -n "$1" ]; then | ||
$1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ DerivedData | |
*.hmap | ||
*.ipa | ||
*.xcuserstate | ||
ios/.xcode.env.local | ||
|
||
# Android/IntelliJ | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This `.xcode.env` file is versioned and is used to source the environment | ||
# used when running script phases inside Xcode. | ||
# To customize your local environment, you can create an `.xcode.env.local` | ||
# file that is not versioned. | ||
|
||
# NODE_BINARY variable contains the PATH to the node executable. | ||
# | ||
# Customize the NODE_BINARY variable here. | ||
# For example, to use nvm with brew, add the following line | ||
# . "$(brew --prefix nvm)/nvm.sh" --no-use | ||
export NODE_BINARY=$(command -v node) |