Preload Yarn PnP and add autolinking fallback in Podfile - #53723
Conversation
Summary: - Preload .pnp.cjs via NODE_OPTIONS so Node resolves RN scripts under Yarn PnP during [!] No `Podfile' found in the project directory.. - Wrap with a safe fallback that derives from when CLI config fails. Motivation: CocoaPods executes Node without Yarn PnP hooks, causing failures like: - Cannot find module - Autolinking exit advising to install This change makes the iOS template resilient in PnP and non-standard setups. Behavior: - No-op on non-PnP projects (gated by existence of ). - Preserves default behavior when CLI config works. Test Plan: 1) Yarn 3 PnP app from template: yarn install v1.22.22 [1/4] Resolving packages... [2/4] Fetching packages... info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. succeeds; Codegen runs; Pods project generates. 2) Non-PnP app: absent; [!] No `Podfile' found in the project directory. behavior unchanged.
6e5debc to
aa88314
Compare
027045c to
10cc23a
Compare
|
Because Danger CI kept failing on the changelog format (even though it was written correctly), I decided to keep the PR description short for now. Preload Yarn PnP runtime and add a safe fallback for
Motivation: CocoaPods invokes Node without Yarn PnP hooks, which leads to failures such as:
This change is a no-op for non-PnP projects and preserves default behavior when CLI config resolution succeeds. Test PlanPnP project (Yarn 3, Plug’n’Play)npx @react-native-community/cli@latest init AwesomeProject
cd AwesomeProject
corepack enable (if needed)
yarn set version berry (if not already on Yarn 3)
yarn config set nodeLinker pnp
yarn install
npx pod-installValidate:
Non-PnP project (classic
|
Removed the nonessential YARN_IGNORE_ENGINES line to keep the change minimal.
|
https://github.com/facebook/react-native/actions/runs/17631368517/job/50099276962?pr=53723 The failure doesn't seem to be related to current PR! |
|
This PR is stale because it has been open for 180 days with no activity. It will be closed in 7 days unless you comment on it or remove the "Stale" label. |
|
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |


Changelog:
[iOS] [Fixed] - Fix autolinking under Yarn PnP in the HelloWorld Podfile.
Summary
Make the HelloWorld iOS Podfile robust under Yarn 3 Plug’n’Play by preloading PnP and adding a safe fallback.
Test Plan
yarn install→npx pod-install→ codegen runs, Pods generated, no "react_native_pods.rb" error, iOS build OK.yarn install(ornpm i) →npx pod-install→ behavior unchanged.