mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add add_dependency function to ract_native_pods and Migrate React-RCTAppDelegate (#41355)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41355 This change expose a new API to react_native_pod to add dependencies that automatically configure their search paths when using frameworksa and with multiple Apple platforms. It also migrates React-RCTAppDelegate to this new mechanism to test that it works. ## Context Last week I helped macOS to work with static framework. When multiple platforms are specified, frameworks are build in two variants, the iOS and macOS one. This break all the HEADER_SEARCH_PATHS as now we have to properly specify the base folder from which the search path is generated. See also [this PR](https://github.com/microsoft/react-native-macos/pull/1967) where I manually make MacOS work with `use_framewroks!` ## Changelog: [Internal] - Add helper function to create header_search_path Reviewed By: shwanton Differential Revision: D51029484 fbshipit-source-id: 77dfe85419d495f7327a2f484d33f9ed8701e00d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
befc6d4004
commit
e1092b4e3c
@@ -21,7 +21,6 @@ folly_compiler_flags = folly_flags + ' ' + '-Wno-comma -Wno-shorten-64-to-32'
|
||||
|
||||
is_new_arch_enabled = ENV["RCT_NEW_ARCH_ENABLED"] == "1"
|
||||
use_hermes = ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == '1'
|
||||
use_frameworks = ENV['USE_FRAMEWORKS'] != nil
|
||||
|
||||
new_arch_enabled_flag = (is_new_arch_enabled ? " -DRCT_NEW_ARCH_ENABLED" : "")
|
||||
is_fabric_enabled = is_new_arch_enabled || ENV["RCT_FABRIC_ENABLED"]
|
||||
@@ -43,21 +42,7 @@ header_search_paths = [
|
||||
].concat(use_hermes ? [
|
||||
"$(PODS_ROOT)/Headers/Public/React-hermes",
|
||||
"$(PODS_ROOT)/Headers/Public/hermes-engine"
|
||||
] : []).concat(use_frameworks ? [
|
||||
"$(PODS_CONFIGURATION_BUILD_DIR)/React-Fabric/React_Fabric.framework/Headers/",
|
||||
"$(PODS_CONFIGURATION_BUILD_DIR)/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx/",
|
||||
"$(PODS_CONFIGURATION_BUILD_DIR)/React-graphics/React_graphics.framework/Headers/",
|
||||
"$(PODS_CONFIGURATION_BUILD_DIR)/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
|
||||
"$(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-RuntimeApple/React_RuntimeApple.framework/Headers",
|
||||
"$(PODS_CONFIGURATION_BUILD_DIR)/React-RuntimeCore/React_RuntimeCore.framework/Headers",
|
||||
"$(PODS_CONFIGURATION_BUILD_DIR)/React-RCTFabric/RCTFabric.framework/Headers/",
|
||||
"$(PODS_CONFIGURATION_BUILD_DIR)/React-utils/React_utils.framework/Headers/",
|
||||
"$(PODS_CONFIGURATION_BUILD_DIR)/React-debug/React_debug.framework/Headers/",
|
||||
"$(PODS_CONFIGURATION_BUILD_DIR)/React-runtimescheduler/React_runtimescheduler.framework/Headers/",
|
||||
"$(PODS_CONFIGURATION_BUILD_DIR)/React-rendererdebug/React_rendererdebug.framework/Headers/",
|
||||
] : []).map{|p| "\"#{p}\""}.join(" ")
|
||||
] : [])
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "React-RCTAppDelegate"
|
||||
@@ -87,18 +72,19 @@ Pod::Spec.new do |s|
|
||||
s.dependency "RCT-Folly"
|
||||
s.dependency "RCTRequired"
|
||||
s.dependency "RCTTypeSafety"
|
||||
s.dependency "ReactCommon/turbomodule/core"
|
||||
s.dependency "React-RCTNetwork"
|
||||
s.dependency "React-RCTImage"
|
||||
s.dependency "React-NativeModulesApple"
|
||||
s.dependency "React-CoreModules"
|
||||
s.dependency "React-nativeconfig"
|
||||
s.dependency "React-runtimescheduler"
|
||||
s.dependency "React-RCTFabric"
|
||||
|
||||
add_dependency(s, "ReactCommon", :subspec => "turbomodule/core", :additional_framework_paths => ["react/nativemodule/core"])
|
||||
add_dependency(s, "React-NativeModulesApple")
|
||||
add_dependency(s, "React-runtimescheduler")
|
||||
add_dependency(s, "React-RCTFabric", :framework_name => "RCTFabric")
|
||||
|
||||
if is_new_arch_enabled
|
||||
s.dependency "React-RuntimeCore"
|
||||
s.dependency "React-RuntimeApple"
|
||||
add_dependency(s, "React-RuntimeCore")
|
||||
add_dependency(s, "React-RuntimeApple")
|
||||
if use_hermes
|
||||
s.dependency "React-RuntimeHermes"
|
||||
end
|
||||
@@ -111,11 +97,11 @@ Pod::Spec.new do |s|
|
||||
end
|
||||
|
||||
if is_new_arch_enabled
|
||||
s.dependency "React-Fabric"
|
||||
s.dependency "React-graphics"
|
||||
s.dependency "React-utils"
|
||||
s.dependency "React-debug"
|
||||
s.dependency "React-rendererdebug"
|
||||
add_dependency(s, "React-Fabric", :additional_framework_paths => ["react/renderer/components/view/platform/cxx"])
|
||||
add_dependency(s, "React-graphics", :additional_framework_paths => ["react/renderer/graphics/platform/ios"])
|
||||
add_dependency(s, "React-utils")
|
||||
add_dependency(s, "React-debug")
|
||||
add_dependency(s, "React-rendererdebug")
|
||||
|
||||
rel_path_from_pods_root_to_app = Pathname.new(ENV['APP_PATH']).relative_path_from(Pod::Config.instance.installation_root)
|
||||
rel_path_from_pods_to_app = Pathname.new(ENV['APP_PATH']).relative_path_from(File.join(Pod::Config.instance.installation_root, 'Pods'))
|
||||
|
||||
@@ -202,6 +202,27 @@ def folly_flags()
|
||||
return NewArchitectureHelper.folly_compiler_flags
|
||||
end
|
||||
|
||||
# Add a dependency to a spec, making sure that the HEADER_SERACH_PATHS are set properly.
|
||||
# This function automate the requirement to specify the HEADER_SEARCH_PATHS which was error prone
|
||||
# and hard to pull out properly to begin with.
|
||||
# Secondly, it prepares the podspec to work also with other platforms, because this function is
|
||||
# able to generate search paths that are compatible with macOS and other platform if specified by
|
||||
# the $RN_PLATFORMS variable.
|
||||
# To generate Header Search Paths for multiple platforms, define in your Podfile or Ruby infra a
|
||||
# $RN_PLATFORMS static variable with the list of supported platforms, for example:
|
||||
# `$RN_PLATFORMS = ["iOS", "macOS"]`
|
||||
#
|
||||
# Parameters:
|
||||
# - spec: the spec that needs to be modified
|
||||
# - pod_name: the name of the dependency we had to add to the spec
|
||||
# - additional_framework_paths: additional sub paths we had to add to the HEADER_SEARCH_PATH
|
||||
# - version: the version of the pod_name the spec needs to depend on
|
||||
# - base_dir: Base directory from where we need to start looking. Defaults to PODS_CONFIGURATION_BUILD_DIR
|
||||
def add_dependency(spec, pod_name, subspec: nil, additional_framework_paths: [], framework_name: nil, version: nil, base_dir: "PODS_CONFIGURATION_BUILD_DIR")
|
||||
fixed_framework_name = framework_name != nil ? framework_name : pod_name.gsub("-", "_") # frameworks can't have "-" in their name
|
||||
ReactNativePodsUtils.add_dependency(spec, pod_name, base_dir, fixed_framework_name, :additional_paths => additional_framework_paths, :version => version)
|
||||
end
|
||||
|
||||
# This function can be used by library developer to prepare their modules for the New Architecture.
|
||||
# It passes the Folly Flags to the module, it configures the search path and installs some New Architecture specific dependencies.
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user