Commit ea38382
Fix REACT_NATIVE_PATH resolution when Pods/ is a symlink (facebook#56453)
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
fbshipit-source-id: b92e83e8491b9e947245e149f0fe8f4b3b81c2ad1 parent cdfed83 commit ea38382
4 files changed
Lines changed: 35 additions & 8 deletions
File tree
- packages/react-native/scripts
- codegen/generate-artifacts-executor
- react_native_pods_utils
- xcode
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
85 | 87 | | |
86 | | - | |
87 | | - | |
88 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
89 | 95 | | |
90 | 96 | | |
91 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
534 | | - | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
535 | 544 | | |
536 | 545 | | |
537 | 546 | | |
| |||
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
40 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
41 | 47 | | |
42 | 48 | | |
43 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
21 | 27 | | |
22 | 28 | | |
23 | 29 | | |
| |||
0 commit comments