Skip to content

Fix REACT_NATIVE_PATH resolution when Pods/ is a symlink (#56453)#56453

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

Fix REACT_NATIVE_PATH resolution when Pods/ is a symlink (#56453)#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.

Reviewed By: cipolleschi

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.

@meta-codesync meta-codesync Bot changed the title Fix REACT_NATIVE_PATH resolution when Pods/ is a symlink Fix REACT_NATIVE_PATH resolution when Pods/ is a symlink (#56453) Apr 22, 2026
@huntie huntie force-pushed the export-D100830088 branch from fe5fff4 to 8fcf8f0 Compare April 22, 2026 12:44
huntie added a commit to huntie/react-native that referenced this pull request Apr 22, 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.

Reviewed By: cipolleschi

Differential Revision: D100830088
)

Summary:
Pull Request resolved: facebook#56453

**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.

Reviewed By: cipolleschi

Differential Revision: D100830088
@huntie huntie force-pushed the export-D100830088 branch from 8fcf8f0 to 49cf01d Compare April 22, 2026 12:48
@meta-codesync meta-codesync Bot closed this in ea38382 Apr 22, 2026
@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @huntie in ea38382

When will my fix make it into a release? | How to file a pick request?

@react-native-bot react-native-bot added the Merged This PR has been merged. label Apr 22, 2026
@huntie huntie deleted the export-D100830088 branch April 22, 2026 13:43
@facebook-github-tools
Copy link
Copy Markdown

This pull request has been reverted by 78190b4.

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 Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner Reverted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants