Skip to content

Fix REACT_NATIVE_PATH resolution when Pods/ is a symlink#56453

Open
huntie wants to merge 1 commit intofacebook:mainfrom
huntie:export-D100830088
Open

Fix REACT_NATIVE_PATH resolution when Pods/ is a symlink#56453
huntie wants to merge 1 commit intofacebook:mainfrom
huntie:export-D100830088

Conversation

@huntie
Copy link
Copy Markdown
Member

@huntie huntie commented Apr 15, 2026

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

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
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 15, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Apr 15, 2026

@huntie has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100830088.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant