Skip to content

Commit af3dfba

Browse files
danilobuergerfacebook-github-bot
authored andcommitted
Move cocoapods cli native_modules require from template to rn scripts (#34215)
Summary: This resolves issues where the node_modules structure is not hoisted (like with pnpm). Since the template does not directly depend on the cli, it doesn't exist in the pnpm node_modules root. Moving it to the rn scripts makes sure that the relative require starts in the correct directory for both hoisted and pnpm structures. ## Changelog [iOS] [Fixed] - Fix cocoapods cli native_modules require for pnpm node_modules Pull Request resolved: #34215 Test Plan: 1. react-native init 2. rm -rf node_modules 3. pnpm i 4. bundle install 5. bundle exec pod install --project-directory=ios This should succeed. Without the patch, it will fail with ``` [!] Invalid `Podfile` file: cannot load such file -- /.../node_modules/react-native-community/cli-platform-ios/native_modules. # from /.../ios/Podfile:2 # ------------------------------------------- # require_relative '../node_modules/react-native/scripts/react_native_pods' > require_relative '../node_modules/react-native-community/cli-platform-ios/native_modules' # # ------------------------------------------- ``` Reviewed By: cortinico Differential Revision: D37959152 Pulled By: cipolleschi fbshipit-source-id: 7fa9af4a8c153cfd38360f57eca415a8c252dbd5
1 parent 46a9edc commit af3dfba

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"scripts/xcode/with-environment.sh",
5050
"scripts/launchPackager.bat",
5151
"scripts/launchPackager.command",
52+
"scripts/native_modules.rb",
5253
"scripts/node-binary.sh",
5354
"scripts/packager.sh",
5455
"scripts/packager-reporter.js",

scripts/native_modules.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# This source code is licensed under the MIT license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
require_relative '../../@react-native-community/cli-platform-ios/native_modules'

template/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require_relative '../node_modules/react-native/scripts/react_native_pods'
2-
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
2+
require_relative '../node_modules/react-native/scripts/native_modules'
33

44
platform :ios, '12.4'
55
install! 'cocoapods', :deterministic_uuids => false

0 commit comments

Comments
 (0)