Fix REACT_NATIVE_PATH resolution when Pods/ is a symlink#56453
Open
huntie wants to merge 1 commit intofacebook:mainfrom
Open
Fix REACT_NATIVE_PATH resolution when Pods/ is a symlink#56453huntie wants to merge 1 commit intofacebook:mainfrom
huntie wants to merge 1 commit intofacebook:mainfrom
Conversation
Summary:
**Problem**
On Meta's virtual filesystem, we've started making `Pods/` a symlink for performance reasons.
The `REACT_NATIVE_PATH` Xcode build setting was constructed as `${PODS_ROOT}/../<relative_path>`, assuming that `${PODS_ROOT}/..` equals the Podfile directory (`ios/`). When `Pods/` is a symlink to a different filesystem depth, Xcode resolves `${PODS_ROOT}` to the physical target, and `..` traverses the wrong tree — landing one directory too high and producing a nonexistent path.
This broke four Xcode script phases at build time: `hermes-engine`, `ReactNativeDependencies`, `React-Core-prebuilt`, and `ReactCodegen`.
**Root cause**
The `$PODS_ROOT/..` idiom appears in four independent locations across Ruby, JavaScript, and shell layers. Each assumes the Pods directory is a direct child of the Podfile directory, which breaks when Pods/ is a symlink to a different filesystem depth.
**Fix**
All four sites are patched with the same approach: a new `PODFILE_DIR` Xcode build setting (set to the absolute Podfile directory path at pod install time) replaces the broken `$PODS_ROOT/..` derivation, with a fallback to the old behavior for backward compatibility.
**Changed files**
- **react_native_pods.rb** — Constructs the `REACT_NATIVE_PATH` build setting in `react_native_post_install`. Now resolves both the Pods directory and the react-native path to their real (physical) filesystem locations via `Pathname#realpath` before computing the relative path. Also adds the new `PODFILE_DIR` build setting.
- **with-environment.sh** — Sourced by script phases to set up `NODE_BINARY`. Located `.xcode.env` via `$PODS_ROOT/../.xcode.env`. Now uses `$PODFILE_DIR` with fallback.
- **script_phases.rb** — Ruby ERB template that generates shell scripts for codegen build phases. Used `pushd "$PODS_ROOT/../"` to derive the Podfile directory. Now uses `$PODFILE_DIR` with fallback.
- **generateReactCodegenPodspec.js** — JavaScript template that generates the ReactCodegen.podspec "Generate Specs" script phase. Had its own hardcoded `pushd "$PODS_ROOT/../"`. Now uses `$PODFILE_DIR` with fallback.
Differential Revision: D100830088
|
@huntie has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100830088. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Problem
On Meta's virtual filesystem, we've started making
Pods/a symlink for performance reasons.The
REACT_NATIVE_PATHXcode build setting was constructed as${PODS_ROOT}/../<relative_path>, assuming that${PODS_ROOT}/..equals the Podfile directory (ios/). WhenPods/is a symlink to a different filesystem depth, Xcode resolves${PODS_ROOT}to the physical target, and..traverses the wrong tree — landing one directory too high and producing a nonexistent path.This broke four Xcode script phases at build time:
hermes-engine,ReactNativeDependencies,React-Core-prebuilt, andReactCodegen.Root cause
The
$PODS_ROOT/..idiom appears in four independent locations across Ruby, JavaScript, and shell layers. Each assumes the Pods directory is a direct child of the Podfile directory, which breaks when Pods/ is a symlink to a different filesystem depth.Fix
All four sites are patched with the same approach: a new
PODFILE_DIRXcode build setting (set to the absolute Podfile directory path at pod install time) replaces the broken$PODS_ROOT/..derivation, with a fallback to the old behavior for backward compatibility.Changed files
REACT_NATIVE_PATHbuild setting inreact_native_post_install. Now resolves both the Pods directory and the react-native path to their real (physical) filesystem locations viaPathname#realpathbefore computing the relative path. Also adds the newPODFILE_DIRbuild setting.NODE_BINARY. Located.xcode.envvia$PODS_ROOT/../.xcode.env. Now uses$PODFILE_DIRwith fallback.pushd "$PODS_ROOT/../"to derive the Podfile directory. Now uses$PODFILE_DIRwith fallback.pushd "$PODS_ROOT/../". Now uses$PODFILE_DIRwith fallback.Differential Revision: D100830088