Always install all the pods (#41588)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41588

This change always installs all the Pods for both architecture.
This unify the behavior between iOS and Android.

## Changelog:
[Internal] - Always install all the pods

## Facebook:
The inly four pods that are changed when flipping between the new and the old arch with RNTester are:
- MyNativeView
- NativeCxxModuleExample
- React-RCTAppDelegate
- ScreenshotManager
The only change there is the RCt_NEW_ARCH_ENABLED flag being set or not in those pods

Reviewed By: dmytrorykun

Differential Revision: D51494498

fbshipit-source-id: 4cafdef4a4c2b86381067373aed27ed18524e4be
This commit is contained in:
Riccardo Cipolleschi
2023-11-22 03:50:29 -08:00
committed by Facebook GitHub Bot
parent a6076924bf
commit 6b5320540a
5 changed files with 26 additions and 72 deletions
@@ -80,42 +80,33 @@ Pod::Spec.new do |s|
add_dependency(s, "React-NativeModulesApple") add_dependency(s, "React-NativeModulesApple")
add_dependency(s, "React-runtimescheduler") add_dependency(s, "React-runtimescheduler")
add_dependency(s, "React-RCTFabric", :framework_name => "RCTFabric") add_dependency(s, "React-RCTFabric", :framework_name => "RCTFabric")
add_dependency(s, "React-RuntimeCore")
if is_new_arch_enabled add_dependency(s, "React-RuntimeApple")
add_dependency(s, "React-RuntimeCore") add_dependency(s, "React-Fabric", :additional_framework_paths => ["react/renderer/components/view/platform/cxx"])
add_dependency(s, "React-RuntimeApple") add_dependency(s, "React-graphics", :additional_framework_paths => ["react/renderer/graphics/platform/ios"])
if use_hermes add_dependency(s, "React-utils")
s.dependency "React-RuntimeHermes" add_dependency(s, "React-debug")
end add_dependency(s, "React-rendererdebug")
end
if use_hermes if use_hermes
s.dependency "React-hermes" s.dependency "React-hermes"
s.dependency "React-RuntimeHermes"
else else
s.dependency "React-jsc" s.dependency "React-jsc"
end end
if is_new_arch_enabled rel_path_from_pods_root_to_app = Pathname.new(ENV['APP_PATH']).relative_path_from(Pod::Config.instance.installation_root)
add_dependency(s, "React-Fabric", :additional_framework_paths => ["react/renderer/components/view/platform/cxx"]) rel_path_from_pods_to_app = Pathname.new(ENV['APP_PATH']).relative_path_from(File.join(Pod::Config.instance.installation_root, 'Pods'))
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) s.script_phases = {
rel_path_from_pods_to_app = Pathname.new(ENV['APP_PATH']).relative_path_from(File.join(Pod::Config.instance.installation_root, 'Pods')) :name => "Generate Legacy Components Interop",
:script => "
s.script_phases = {
:name => "Generate Legacy Components Interop",
:script => "
WITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\" WITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"
source $WITH_ENVIRONMENT source $WITH_ENVIRONMENT
${NODE_BINARY} ${REACT_NATIVE_PATH}/scripts/codegen/generate-legacy-interop-components.js -p #{rel_path_from_pods_to_app} -o ${REACT_NATIVE_PATH}/Libraries/AppDelegate ${NODE_BINARY} ${REACT_NATIVE_PATH}/scripts/codegen/generate-legacy-interop-components.js -p #{rel_path_from_pods_to_app} -o ${REACT_NATIVE_PATH}/Libraries/AppDelegate
", ",
:execution_position => :before_compile, :execution_position => :before_compile,
:input_files => ["#{rel_path_from_pods_root_to_app}/react-native.config.js"], :input_files => ["#{rel_path_from_pods_root_to_app}/react-native.config.js"],
:output_files => ["${REACT_NATIVE_PATH}/Libraries/AppDelegate/RCTLegacyInteropComponents.mm"], :output_files => ["${REACT_NATIVE_PATH}/Libraries/AppDelegate/RCTLegacyInteropComponents.mm"],
} }
end
end end
@@ -93,25 +93,6 @@ class CodegenUtilsTests < Test::Unit::TestCase
# ========================== # # ========================== #
# Test - GetReactCodegenSpec # # Test - GetReactCodegenSpec #
# ========================== # # ========================== #
def testGetReactCodegenSpec_whenFabricDisabledAndNoScriptPhases_generatesAPodspec
# Arrange
FileMock.files_to_read('package.json' => '{ "version": "99.98.97"}')
# Act
podspec = CodegenUtils.new().get_react_codegen_spec(
'package.json',
:fabric_enabled => false,
:hermes_enabled => true,
:script_phases => nil,
:file_manager => FileMock
)
# Assert
assert_equal(podspec, get_podspec_no_fabric_no_script())
assert_equal(Pod::UI.collected_messages, [])
end
def testGetReactCodegenSpec_whenFabricEnabledAndScriptPhases_generatesAPodspec def testGetReactCodegenSpec_whenFabricEnabledAndScriptPhases_generatesAPodspec
# Arrange # Arrange
FileMock.files_to_read('package.json' => '{ "version": "99.98.97"}') FileMock.files_to_read('package.json' => '{ "version": "99.98.97"}')
@@ -119,7 +100,6 @@ class CodegenUtilsTests < Test::Unit::TestCase
# Act # Act
podspec = CodegenUtils.new().get_react_codegen_spec( podspec = CodegenUtils.new().get_react_codegen_spec(
'package.json', 'package.json',
:fabric_enabled => true,
:hermes_enabled => true, :hermes_enabled => true,
:script_phases => "echo Test Script Phase", :script_phases => "echo Test Script Phase",
:file_manager => FileMock :file_manager => FileMock
@@ -138,7 +118,7 @@ class CodegenUtilsTests < Test::Unit::TestCase
# Act # Act
podspec = CodegenUtils.new().get_react_codegen_spec( podspec = CodegenUtils.new().get_react_codegen_spec(
'package.json', 'package.json',
:fabric_enabled => true,
:hermes_enabled => true, :hermes_enabled => true,
:script_phases => nil, :script_phases => nil,
:file_manager => FileMock :file_manager => FileMock
@@ -380,11 +360,9 @@ class CodegenUtilsTests < Test::Unit::TestCase
:app_path => app_path, :app_path => app_path,
:config_file_dir => "", :config_file_dir => "",
:config_key => "codegenConfig", :config_key => "codegenConfig",
:fabric_enabled => false,
:react_native_path => "../node_modules/react-native"} :react_native_path => "../node_modules/react-native"}
]) ])
assert_equal(codegen_utils_mock.get_react_codegen_spec_params, [{ assert_equal(codegen_utils_mock.get_react_codegen_spec_params, [{
:fabric_enabled => false,
:folly_version=>"2023.08.07.00", :folly_version=>"2023.08.07.00",
:package_json_file => "#{app_path}/ios/../node_modules/react-native/package.json", :package_json_file => "#{app_path}/ios/../node_modules/react-native/package.json",
:script_phases => "echo TestScript" :script_phases => "echo TestScript"
@@ -58,7 +58,6 @@ class CodegenUtilsMock
) )
@get_react_codegen_script_phases_params.push({ @get_react_codegen_script_phases_params.push({
app_path: app_path, app_path: app_path,
fabric_enabled: fabric_enabled,
config_file_dir: config_file_dir, config_file_dir: config_file_dir,
react_native_path: react_native_path, react_native_path: react_native_path,
config_key: config_key config_key: config_key
@@ -66,11 +65,10 @@ class CodegenUtilsMock
return @react_codegen_script_phases return @react_codegen_script_phases
end end
def get_react_codegen_spec(package_json_file, folly_version: '2023.08.07.00', fabric_enabled: false, hermes_enabled: true, script_phases: nil) def get_react_codegen_spec(package_json_file, folly_version: '2023.08.07.00', hermes_enabled: true, script_phases: nil)
@get_react_codegen_spec_params.push({ @get_react_codegen_spec_params.push({
package_json_file: package_json_file, package_json_file: package_json_file,
folly_version: folly_version, folly_version: folly_version,
fabric_enabled: fabric_enabled,
script_phases: script_phases script_phases: script_phases
}) })
return @react_codegen_spec return @react_codegen_spec
@@ -66,11 +66,10 @@ class CodegenUtils
# #
# Parameters # Parameters
# - package_json_file: the path to the `package.json`, required to extract the proper React Native version # - package_json_file: the path to the `package.json`, required to extract the proper React Native version
# - fabric_enabled: whether fabric is enabled or not.
# - hermes_enabled: whether hermes is enabled or not. # - hermes_enabled: whether hermes is enabled or not.
# - script_phases: whether we want to add some build script phases or not. # - script_phases: whether we want to add some build script phases or not.
# - file_manager: a class that implements the `File` interface. Defaults to `File`, the Dependency can be injected for testing purposes. # - file_manager: a class that implements the `File` interface. Defaults to `File`, the Dependency can be injected for testing purposes.
def get_react_codegen_spec(package_json_file, folly_version: '2023.08.07.00', fabric_enabled: false, hermes_enabled: true, script_phases: nil, file_manager: File) def get_react_codegen_spec(package_json_file, folly_version: '2023.08.07.00', hermes_enabled: true, script_phases: nil, file_manager: File)
package = JSON.parse(file_manager.read(package_json_file)) package = JSON.parse(file_manager.read(package_json_file))
version = package['version'] version = package['version']
new_arch_disabled = ENV['RCT_NEW_ARCH_ENABLED'] != "1" new_arch_disabled = ENV['RCT_NEW_ARCH_ENABLED'] != "1"
@@ -136,18 +135,13 @@ class CodegenUtils
"React-NativeModulesApple": [], "React-NativeModulesApple": [],
"glog": [], "glog": [],
"DoubleConversion": [], "DoubleConversion": [],
}
}
if fabric_enabled
spec[:'dependencies'].merge!({
'React-graphics': [], 'React-graphics': [],
'React-rendererdebug': [], 'React-rendererdebug': [],
'React-Fabric': [], 'React-Fabric': [],
'React-debug': [], 'React-debug': [],
'React-utils': [], 'React-utils': [],
}); }
end }
if hermes_enabled if hermes_enabled
spec[:'dependencies'].merge!({ spec[:'dependencies'].merge!({
@@ -313,7 +307,6 @@ class CodegenUtils
react_codegen_spec = codegen_utils.get_react_codegen_spec( react_codegen_spec = codegen_utils.get_react_codegen_spec(
file_manager.join(relative_installation_root, react_native_path, "package.json"), file_manager.join(relative_installation_root, react_native_path, "package.json"),
:folly_version => folly_version, :folly_version => folly_version,
:fabric_enabled => fabric_enabled,
:hermes_enabled => hermes_enabled, :hermes_enabled => hermes_enabled,
:script_phases => script_phases :script_phases => script_phases
) )
@@ -103,6 +103,8 @@ def use_react_native! (
ReactNativePodsUtils.warn_if_not_on_arm64() ReactNativePodsUtils.warn_if_not_on_arm64()
build_codegen!(prefix, relative_path_from_current)
# The Pods which should be included in all projects # The Pods which should be included in all projects
pod 'FBLazyVector', :path => "#{prefix}/Libraries/FBLazyVector" pod 'FBLazyVector', :path => "#{prefix}/Libraries/FBLazyVector"
pod 'RCTRequired', :path => "#{prefix}/Libraries/Required" pod 'RCTRequired', :path => "#{prefix}/Libraries/Required"
@@ -174,15 +176,7 @@ def use_react_native! (
# If the New Arch is turned off, we will use the Old Renderer, though. # If the New Arch is turned off, we will use the Old Renderer, though.
# RNTester always installed Fabric, this change is required to make the template work. # RNTester always installed Fabric, this change is required to make the template work.
setup_fabric!(:react_native_path => prefix) setup_fabric!(:react_native_path => prefix)
setup_bridgeless!(:react_native_path => prefix, :use_hermes => hermes_enabled)
if !fabric_enabled
relative_installation_root = Pod::Config.instance.installation_root.relative_path_from(Pathname.pwd)
build_codegen!(prefix, relative_installation_root)
end
if NewArchitectureHelper.new_arch_enabled
setup_bridgeless!(:react_native_path => prefix, :use_hermes => hermes_enabled)
end
pods_to_update = LocalPodspecPatch.pods_to_update(:react_native_path => prefix) pods_to_update = LocalPodspecPatch.pods_to_update(:react_native_path => prefix)
if !pods_to_update.empty? if !pods_to_update.empty?