Skip to content

Commit e723ca4

Browse files
chrfalchfacebook-github-bot
authored andcommitted
Support dynamic static linkage with prebuilts (#53432)
Summary: To be able to handle cocoapods USE_FRAMEWORKS with both dynamic/static linkage and precompiled we needed a common way to resolve this. The issue was that when using precompiled and USE_FRAMEWORKS our precompiled framework caused the resulting Pods project to only include header files - hence there where no need to change the header_mappings_dir which a lot of the podspecs did. When using precompiled and building with frameworks (USE_FRAMEWORKS) we need to explicitly add the correct path to ReactCodegen when calling `create_header_search_path_for_frameworks` to ensure libraries can access their codegen files. - Added method that handles this in a generic way - Replaced logic for resolving header mappings and module name using the new method `resolve_use_frameworks` in all podspecs. - Add an explicit check to make sure we add the correct path when using frameworks and the pod is ReactCodegen. - Added includes in the NativeCXXModuleExample.cpp file to test this. ## Changelog: [IOS] [FIXED] - Fixed using USE_FRAMEWORKS (static/dynamic) with precompiled binaries Pull Request resolved: #53432 Test Plan: Build RN-Tester with USE_FRAMEWORKS static and dynamic ### Tests ran: ✅ Build with source and no USE_FRAMEWORKS ✅ Build with source and USE_FRAMEWORKS = static 🔴 Build with source and USE_FRAMEWORKS = dynamic Undefined symbols for architecture arm64: "facebook::react::oscompat::getCurrentProcessId()", referenced from: Reviewed By: motiz88 Differential Revision: D81127796 Pulled By: cipolleschi fbshipit-source-id: 1f55bf31240ac93cb8b93751b3e37ff6d517f49b
1 parent 111187f commit e723ca4

39 files changed

Lines changed: 77 additions & 138 deletions

File tree

packages/react-native/React/React-RCTFBReactNativeSpec.podspec

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ Pod::Spec.new do |s|
4545
"HEADER_SEARCH_PATHS" => header_search_paths.join(' '),
4646
}
4747

48-
if ENV['USE_FRAMEWORKS']
49-
s.header_mappings_dir = 'FBReactNativeSpec'
50-
s.module_name = 'React_RCTFBReactNativeSpec'
51-
end
48+
resolve_use_frameworks(s, header_mappings_dir: 'FBReactNativeSpec', module_name: "React_RCTFBReactNativeSpec")
5249

5350
s.dependency "React-jsi"
5451
s.dependency "RCTRequired"

packages/react-native/React/Runtime/React-RCTRuntime.podspec

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ Pod::Spec.new do |s|
3535
s.header_dir = header_dir
3636
s.module_name = module_name
3737

38-
if ENV['USE_FRAMEWORKS']
39-
s.header_mappings_dir = "./"
40-
end
38+
resolve_use_frameworks(s, header_mappings_dir: "./")
4139

4240
s.pod_target_xcconfig = {
4341
"OTHER_CFLAGS" => "$(inherited) " + new_arch_flags,

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ Pod::Spec.new do |s|
3232
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
3333
"DEFINES_MODULE" => "YES" }
3434

35-
if ENV['USE_FRAMEWORKS'] && ReactNativeCoreUtils.build_rncore_from_source()
36-
s.header_mappings_dir = './'
37-
s.module_name = 'React_Fabric'
38-
end
35+
resolve_use_frameworks(s, header_mappings_dir: "./", module_name: "React_Fabric")
3936

4037
s.dependency "React-jsiexecutor"
4138
s.dependency "RCTRequired"

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ Pod::Spec.new do |s|
4949
"HEADER_SEARCH_PATHS" => header_search_path.join(" "),
5050
}
5151

52-
if ENV['USE_FRAMEWORKS']
53-
s.header_mappings_dir = './'
54-
s.module_name = 'React_FabricComponents'
55-
end
52+
resolve_use_frameworks(s, header_mappings_dir: "./", module_name: "React_FabricComponents")
5653

5754
s.dependency "React-jsiexecutor"
5855
s.dependency "RCTRequired"

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ Pod::Spec.new do |s|
5050
"HEADER_SEARCH_PATHS" => header_search_path.join(" ")
5151
}
5252

53-
if ENV['USE_FRAMEWORKS']
54-
s.header_mappings_dir = './'
55-
s.module_name = 'React_FabricImage'
56-
end
53+
resolve_use_frameworks(s, header_mappings_dir: './', module_name: "React_FabricImage")
5754

5855
s.dependency "React-jsiexecutor", version
5956
s.dependency "RCTRequired", version

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ Pod::Spec.new do |s|
3232
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => ["\"$(PODS_TARGET_SRCROOT)\""], "USE_HEADERMAP" => "YES",
3333
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard() }
3434

35-
if ENV['USE_FRAMEWORKS']
36-
s.header_mappings_dir = './'
37-
s.module_name = 'React_Mapbuffer'
38-
end
35+
resolve_use_frameworks(s, header_mappings_dir: './', module_name: "React_Mapbuffer")
3936

4037
add_dependency(s, "React-debug")
4138
add_rn_third_party_dependencies(s)

packages/react-native/ReactCommon/ReactCommon.podspec

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ Pod::Spec.new do |s|
3232
"DEFINES_MODULE" => "YES",
3333
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
3434
"GCC_WARN_PEDANTIC" => "YES" }
35-
if ENV['USE_FRAMEWORKS'] && ReactNativeCoreUtils.build_rncore_from_source()
36-
s.header_mappings_dir = './'
37-
end
35+
36+
resolve_use_frameworks(s, header_mappings_dir: './')
3837

3938
add_rn_third_party_dependencies(s)
4039
add_rncore_dependency(s)

packages/react-native/ReactCommon/hermes/executor/React-jsitracing.podspec

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ Pod::Spec.new do |s|
3232
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
3333
"GCC_WARN_PEDANTIC" => "YES" }
3434

35-
if ENV['USE_FRAMEWORKS']
36-
s.header_mappings_dir = './'
37-
s.module_name = 'React_jsitracing'
38-
end
35+
resolve_use_frameworks(s, header_mappings_dir: './', module_name: "React_jsitracing")
3936

4037
s.dependency "React-jsi"
4138
end

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ Pod::Spec.new do |s|
3333
"USE_HEADERMAP" => "YES",
3434
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard()
3535
}
36-
if ENV['USE_FRAMEWORKS'] && ReactNativeCoreUtils.build_rncore_from_source()
37-
s.header_mappings_dir = '../'
38-
s.module_name = 'React_jserrorhandler'
39-
end
36+
37+
resolve_use_frameworks(s, header_mappings_dir: '../', module_name: "React_jserrorhandler")
4038

4139
s.dependency "React-jsi"
4240
s.dependency "React-cxxreact"

packages/react-native/ReactCommon/jsinspector-modern/React-jsinspector.podspec

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ Pod::Spec.new do |s|
4444
"PUBLIC_HEADERS_FOLDER_PATH" => "#{module_name}.framework/Headers/#{header_dir}"
4545
} : {})
4646

47-
if ENV['USE_FRAMEWORKS']
48-
s.module_name = module_name
49-
end
47+
resolve_use_frameworks(s, module_name: module_name)
5048

49+
add_dependency(s, "React-oscompat") # Needed for USE_FRAMEWORKS=dynamic
5150
s.dependency "React-featureflags"
5251
add_dependency(s, "React-runtimeexecutor", :additional_framework_paths => ["platform/ios"])
5352
s.dependency "React-jsi"

0 commit comments

Comments
 (0)