Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build failure on iOS with pnpm and use_frameworks! #38158

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ header_search_paths = [
if ENV["USE_FRAMEWORKS"]
header_search_paths = header_search_paths.concat([
"\"$(PODS_CONFIGURATION_BUILD_DIR)/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core\"",
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers\""
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers\"",
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers/build/generated/ios\"",
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-Codegen/React_Codegen.framework/Headers/build/generated/ios\"",
Comment on lines +32 to +33
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is generating code inside these folders? The default setup for Codegen does not do that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually not sure, that's a react-native iOS build detail beyond my understanding.

To make this patch I repeatedly compiled the simple reproduction here https://github.com/evelant/rn072-ios-frameworks-static-failure and noted which pod and headers it was failing on each time. I located the missing header files in the build output and added those locations to the search path.

After repeating the above enough times all the headers resolved correctly and the project compiled successfully.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think it's due to this line https://github.com/facebook/react-native/pull/38158/files#diff-c09e8b79ee60d74ca03bb3960e11fd2155e2391451933b8f6d008a56dfac4e3cR40

When cocoapods copies the headers using the full path for header_mappings_dir this is where they end up.

"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-Codegen/React_Codegen.framework/Headers\""
])
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ header_search_paths = [
if ENV["USE_FRAMEWORKS"]
header_search_paths = header_search_paths.concat([
"\"$(PODS_CONFIGURATION_BUILD_DIR)/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core\"",
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers\""
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers\"",
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers/build/generated/ios\"",
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-Codegen/React_Codegen.framework/Headers/build/generated/ios\"",
cipolleschi marked this conversation as resolved.
Show resolved Hide resolved
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-Codegen/React_Codegen.framework/Headers\"",

])
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ header_search_paths = [
if ENV["USE_FRAMEWORKS"]
header_search_paths = header_search_paths.concat([
"\"$(PODS_CONFIGURATION_BUILD_DIR)/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core\"",
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers\""
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers\"",
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers/build/generated/ios\"",
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-Codegen/React_Codegen.framework/Headers/build/generated/ios\"",
cipolleschi marked this conversation as resolved.
Show resolved Hide resolved
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-Codegen/React_Codegen.framework/Headers\"",
])
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ header_search_paths = [
if ENV["USE_FRAMEWORKS"]
header_search_paths = header_search_paths.concat([
"\"$(PODS_CONFIGURATION_BUILD_DIR)/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core\"",
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers\""
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers\"",
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-Codegen/React_Codegen.framework/Headers/build/generated/ios\"",
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-Codegen/React_Codegen.framework/Headers\""
])
end

Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/ReactCommon/React-Fabric.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Pod::Spec.new do |s|
"DEFINES_MODULE" => "YES" }

if ENV['USE_FRAMEWORKS']
s.header_mappings_dir = './'
s.header_mappings_dir = File.absolute_path('./')
s.module_name = 'React_Fabric'
end

Expand Down
12 changes: 12 additions & 0 deletions packages/react-native/ReactCommon/React-rncore.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ react_native_dependency_path = ENV['REACT_NATIVE_PATH']
# Relative path to react native from current podspec
react_native_sources_path = '..'

header_search_paths = [
"\"$(PODS_TARGET_SRCROOT)\"",
"\"$(PODS_TARGET_SRCROOT)/ReactCommon\"",
]

if ENV["USE_FRAMEWORKS"]
header_search_paths = header_search_paths.concat([
"\"$(PODS_CONFIGURATION_BUILD_DIR)/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core\"",
])
end

Pod::Spec.new do |s|
s.name = "React-rncore"
s.version = version
Expand All @@ -37,6 +48,7 @@ Pod::Spec.new do |s|
s.source = source
s.source_files = "dummyFile.cpp"
s.pod_target_xcconfig = { "USE_HEADERMAP" => "YES",
"HEADER_SEARCH_PATHS" => header_search_paths.join(' '),
cipolleschi marked this conversation as resolved.
Show resolved Hide resolved
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17" }


Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/ReactCommon/ReactCommon.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Pod::Spec.new do |s|
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"GCC_WARN_PEDANTIC" => "YES" }
if ENV['USE_FRAMEWORKS']
s.header_mappings_dir = './'
s.header_mappings_dir = File.absolute_path("./")
cipolleschi marked this conversation as resolved.
Show resolved Hide resolved
end

# TODO (T48588859): Restructure this target to align with dir structure: "react/nativemodule/..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ Pod::Spec.new do |s|

if ENV['USE_FRAMEWORKS']
s.module_name = "React_debug"
s.header_mappings_dir = "../.."
s.header_mappings_dir = File.absolute_path("../..")
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Pod::Spec.new do |s|
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"GCC_WARN_PEDANTIC" => "YES" }
if ENV['USE_FRAMEWORKS']
s.header_mappings_dir = './'
s.header_mappings_dir = File.absolute_path('./')
end

s.source_files = "ReactCommon/**/*.{mm,cpp,h}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Pod::Spec.new do |s|
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"GCC_WARN_PEDANTIC" => "YES" }
if ENV['USE_FRAMEWORKS']
s.header_mappings_dir = './'
s.header_mappings_dir = File.absolute_path('./')
end


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Pod::Spec.new do |s|

if ENV['USE_FRAMEWORKS']
s.module_name = "React_graphics"
s.header_mappings_dir = "../../.."
s.header_mappings_dir = File.absolute_path("../../..")
header_search_paths = header_search_paths + ["\"$(PODS_TARGET_SRCROOT)/platform/ios\""]
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Pod::Spec.new do |s|

if ENV['USE_FRAMEWORKS']
s.module_name = "React_ImageManager"
s.header_mappings_dir = "./"
s.header_mappings_dir = File.absolute_path("./")
header_search_paths = header_search_paths + [
"\"${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers\"",
"\"$(PODS_ROOT)/DoubleConversion\"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Pod::Spec.new do |s|

if ENV['USE_FRAMEWORKS']
s.module_name = "React_runtimescheduler"
s.header_mappings_dir = "../../.."
s.header_mappings_dir = File.absolute_path("../../..")
end

s.dependency "React-jsi"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Pod::Spec.new do |s|

if ENV['USE_FRAMEWORKS']
s.module_name = "React_utils"
s.header_mappings_dir = "../.."
s.header_mappings_dir = File.absolute_path("../..")
end

s.dependency "RCT-Folly", folly_version
Expand Down