Skip to content

Commit 58adc5e

Browse files
evelantfacebook-github-bot
evelant
authored andcommitted
Fix build failure on iOS with pnpm and use_frameworks! (#38158)
Summary: Fix build failure on iOS with pnpm and use_frameworks! due to cocoapods copying symlinked headers to wrong paths When using pnpm all packages are symlinked to node_modules/.pnpm to prevent phantom dependency resolution. This causes react-native iOS build to fail because Cocoapods copies headers to incorrect destinations when they're behind symlinks. The fix resolves absolute paths to the header_mappings_dir at pod install time. With absolute paths cocoapods copies the headers correctly. This commit also adds a few missing header search paths in use_frameworks! mode. Fixes #38140 ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [IOS] [FIXED] - Build failure with pnpm and use_frameworks! due to incorrect header paths For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests Pull Request resolved: #38158 Test Plan: 1. `pnpm pnpx react-native@latest init AwesomeProject` 2. `cd AwesomeProject` 3. `rm -rf node_modules yarn.lock` 4. `mkdir patches` 5. copy [[email protected]](https://github.com/facebook/react-native/files/11937570/react-native%400.72.1.patch) to `patches/` 6. Add patch to package.json ``` "pnpm": { "patchedDependencies": { "[email protected]": "patches/[email protected]" } } ``` 7. `pnpm install` 8. `cd ios` 9. `NO_FLIPPER=1 USE_FRAMEWORKS=static pod install` 10. `cd ..` 11. `pnpm react-native run-ios` Hopefully an automated test of building with `pnpm` can be added to CI. I don't know how to make that happen, hopefully someone at facebook can do it. Reviewed By: dmytrorykun Differential Revision: D47211946 Pulled By: cipolleschi fbshipit-source-id: 87640bd3f32f023c43291213b5291a7b990d7e1f
1 parent 41477c8 commit 58adc5e

File tree

14 files changed

+37
-13
lines changed

14 files changed

+37
-13
lines changed

packages/react-native/Libraries/LinkingIOS/React-RCTLinking.podspec

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ header_search_paths = [
2828
if ENV["USE_FRAMEWORKS"]
2929
header_search_paths = header_search_paths.concat([
3030
"\"$(PODS_CONFIGURATION_BUILD_DIR)/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core\"",
31-
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers\""
31+
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers\"",
32+
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers/build/generated/ios\"",
33+
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-Codegen/React_Codegen.framework/Headers/build/generated/ios\"",
34+
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-Codegen/React_Codegen.framework/Headers\""
3235
])
3336
end
3437

packages/react-native/Libraries/Network/React-RCTNetwork.podspec

+5-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ header_search_paths = [
2828
if ENV["USE_FRAMEWORKS"]
2929
header_search_paths = header_search_paths.concat([
3030
"\"$(PODS_CONFIGURATION_BUILD_DIR)/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core\"",
31-
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers\""
31+
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers\"",
32+
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers/build/generated/ios\"",
33+
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-Codegen/React_Codegen.framework/Headers/build/generated/ios\"",
34+
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-Codegen/React_Codegen.framework/Headers\"",
35+
3236
])
3337
end
3438

packages/react-native/Libraries/Settings/React-RCTSettings.podspec

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ header_search_paths = [
2828
if ENV["USE_FRAMEWORKS"]
2929
header_search_paths = header_search_paths.concat([
3030
"\"$(PODS_CONFIGURATION_BUILD_DIR)/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core\"",
31-
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers\""
31+
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers\"",
32+
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers/build/generated/ios\"",
33+
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-Codegen/React_Codegen.framework/Headers/build/generated/ios\"",
34+
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-Codegen/React_Codegen.framework/Headers\"",
3235
])
3336
end
3437

packages/react-native/Libraries/Vibration/React-RCTVibration.podspec

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ header_search_paths = [
2828
if ENV["USE_FRAMEWORKS"]
2929
header_search_paths = header_search_paths.concat([
3030
"\"$(PODS_CONFIGURATION_BUILD_DIR)/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core\"",
31-
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers\""
31+
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers\"",
32+
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-Codegen/React_Codegen.framework/Headers/build/generated/ios\"",
33+
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-Codegen/React_Codegen.framework/Headers\""
3234
])
3335
end
3436

packages/react-native/ReactCommon/React-Fabric.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Pod::Spec.new do |s|
3737
"DEFINES_MODULE" => "YES" }
3838

3939
if ENV['USE_FRAMEWORKS']
40-
s.header_mappings_dir = './'
40+
s.header_mappings_dir = File.absolute_path('./')
4141
s.module_name = 'React_Fabric'
4242
end
4343

packages/react-native/ReactCommon/React-rncore.podspec

+12
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ react_native_dependency_path = ENV['REACT_NATIVE_PATH']
2626
# Relative path to react native from current podspec
2727
react_native_sources_path = '..'
2828

29+
header_search_paths = [
30+
"\"$(PODS_TARGET_SRCROOT)\"",
31+
"\"$(PODS_TARGET_SRCROOT)/ReactCommon\"",
32+
]
33+
34+
if ENV["USE_FRAMEWORKS"]
35+
header_search_paths = header_search_paths.concat([
36+
"\"$(PODS_CONFIGURATION_BUILD_DIR)/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core\"",
37+
])
38+
end
39+
2940
Pod::Spec.new do |s|
3041
s.name = "React-rncore"
3142
s.version = version
@@ -37,6 +48,7 @@ Pod::Spec.new do |s|
3748
s.source = source
3849
s.source_files = "dummyFile.cpp"
3950
s.pod_target_xcconfig = { "USE_HEADERMAP" => "YES",
51+
"HEADER_SEARCH_PATHS" => header_search_paths.join(' '),
4052
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17" }
4153

4254

packages/react-native/ReactCommon/ReactCommon.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Pod::Spec.new do |s|
3737
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
3838
"GCC_WARN_PEDANTIC" => "YES" }
3939
if ENV['USE_FRAMEWORKS']
40-
s.header_mappings_dir = './'
40+
s.header_mappings_dir = File.absolute_path("./")
4141
end
4242

4343
# TODO (T48588859): Restructure this target to align with dir structure: "react/nativemodule/..."

packages/react-native/ReactCommon/react/debug/React-debug.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ Pod::Spec.new do |s|
3232

3333
if ENV['USE_FRAMEWORKS']
3434
s.module_name = "React_debug"
35-
s.header_mappings_dir = "../.."
35+
s.header_mappings_dir = File.absolute_path("../..")
3636
end
3737
end

packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/React-NativeModulesApple.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Pod::Spec.new do |s|
3737
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
3838
"GCC_WARN_PEDANTIC" => "YES" }
3939
if ENV['USE_FRAMEWORKS']
40-
s.header_mappings_dir = './'
40+
s.header_mappings_dir = File.absolute_path('./')
4141
end
4242

4343
s.source_files = "ReactCommon/**/*.{mm,cpp,h}"

packages/react-native/ReactCommon/react/nativemodule/samples/ReactCommon-Samples.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Pod::Spec.new do |s|
3737
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
3838
"GCC_WARN_PEDANTIC" => "YES" }
3939
if ENV['USE_FRAMEWORKS']
40-
s.header_mappings_dir = './'
40+
s.header_mappings_dir = File.absolute_path('./')
4141
end
4242

4343

packages/react-native/ReactCommon/react/renderer/graphics/React-graphics.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Pod::Spec.new do |s|
4545

4646
if ENV['USE_FRAMEWORKS']
4747
s.module_name = "React_graphics"
48-
s.header_mappings_dir = "../../.."
48+
s.header_mappings_dir = File.absolute_path("../../..")
4949
header_search_paths = header_search_paths + ["\"$(PODS_TARGET_SRCROOT)/platform/ios\""]
5050
end
5151

packages/react-native/ReactCommon/react/renderer/imagemanager/platform/ios/React-ImageManager.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Pod::Spec.new do |s|
4242

4343
if ENV['USE_FRAMEWORKS']
4444
s.module_name = "React_ImageManager"
45-
s.header_mappings_dir = "./"
45+
s.header_mappings_dir = File.absolute_path("./")
4646
header_search_paths = header_search_paths + [
4747
"\"${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers\"",
4848
"\"$(PODS_ROOT)/DoubleConversion\"",

packages/react-native/ReactCommon/react/renderer/runtimescheduler/React-runtimescheduler.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Pod::Spec.new do |s|
4747

4848
if ENV['USE_FRAMEWORKS']
4949
s.module_name = "React_runtimescheduler"
50-
s.header_mappings_dir = "../../.."
50+
s.header_mappings_dir = File.absolute_path("../../..")
5151
end
5252

5353
s.dependency "React-jsi"

packages/react-native/ReactCommon/react/utils/React-utils.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Pod::Spec.new do |s|
4848

4949
if ENV['USE_FRAMEWORKS']
5050
s.module_name = "React_utils"
51-
s.header_mappings_dir = "../.."
51+
s.header_mappings_dir = File.absolute_path("../..")
5252
end
5353

5454
s.dependency "RCT-Folly", folly_version

0 commit comments

Comments
 (0)