Skip to content

Commit

Permalink
Always install all the pods (facebook#41588)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#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
  • Loading branch information
cipolleschi authored and facebook-github-bot committed Nov 22, 2023
1 parent a607692 commit 6b53205
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,42 +80,33 @@ Pod::Spec.new do |s|
add_dependency(s, "React-NativeModulesApple")
add_dependency(s, "React-runtimescheduler")
add_dependency(s, "React-RCTFabric", :framework_name => "RCTFabric")

if is_new_arch_enabled
add_dependency(s, "React-RuntimeCore")
add_dependency(s, "React-RuntimeApple")
if use_hermes
s.dependency "React-RuntimeHermes"
end
end
add_dependency(s, "React-RuntimeCore")
add_dependency(s, "React-RuntimeApple")
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")

if use_hermes
s.dependency "React-hermes"
s.dependency "React-RuntimeHermes"
else
s.dependency "React-jsc"
end

if is_new_arch_enabled
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'))
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'))


s.script_phases = {
: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\"
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
",
:execution_position => :before_compile,
:input_files => ["#{rel_path_from_pods_root_to_app}/react-native.config.js"],
:output_files => ["${REACT_NATIVE_PATH}/Libraries/AppDelegate/RCTLegacyInteropComponents.mm"],
}
end
",
:execution_position => :before_compile,
:input_files => ["#{rel_path_from_pods_root_to_app}/react-native.config.js"],
:output_files => ["${REACT_NATIVE_PATH}/Libraries/AppDelegate/RCTLegacyInteropComponents.mm"],
}
end
Original file line number Diff line number Diff line change
Expand Up @@ -93,33 +93,13 @@ def testGenerateReactCodegenPodspec_whenItHasNotBeenAlreadyGenerated_generatesIt
# ========================== #
# 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
# Arrange
FileMock.files_to_read('package.json' => '{ "version": "99.98.97"}')

# Act
podspec = CodegenUtils.new().get_react_codegen_spec(
'package.json',
:fabric_enabled => true,
:hermes_enabled => true,
:script_phases => "echo Test Script Phase",
:file_manager => FileMock
Expand All @@ -138,7 +118,7 @@ def testGetReactCodegenSpec_whenUseFrameworksAndNewArch_generatesAPodspec
# Act
podspec = CodegenUtils.new().get_react_codegen_spec(
'package.json',
:fabric_enabled => true,

:hermes_enabled => true,
:script_phases => nil,
:file_manager => FileMock
Expand Down Expand Up @@ -380,11 +360,9 @@ def testUseReactCodegenDiscovery_whenParametersAreGood_executeCodegen
:app_path => app_path,
:config_file_dir => "",
:config_key => "codegenConfig",
:fabric_enabled => false,
:react_native_path => "../node_modules/react-native"}
])
assert_equal(codegen_utils_mock.get_react_codegen_spec_params, [{
:fabric_enabled => false,
:folly_version=>"2023.08.07.00",
:package_json_file => "#{app_path}/ios/../node_modules/react-native/package.json",
:script_phases => "echo TestScript"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,17 @@ def get_react_codegen_script_phases(
)
@get_react_codegen_script_phases_params.push({
app_path: app_path,
fabric_enabled: fabric_enabled,
config_file_dir: config_file_dir,
react_native_path: react_native_path,
config_key: config_key
})
return @react_codegen_script_phases
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({
package_json_file: package_json_file,
folly_version: folly_version,
fabric_enabled: fabric_enabled,
script_phases: script_phases
})
return @react_codegen_spec
Expand Down
13 changes: 3 additions & 10 deletions packages/react-native/scripts/cocoapods/codegen_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ def generate_react_codegen_podspec!(spec, codegen_output_dir, file_manager: File
#
# Parameters
# - 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.
# - 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.
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))
version = package['version']
new_arch_disabled = ENV['RCT_NEW_ARCH_ENABLED'] != "1"
Expand Down Expand Up @@ -136,18 +135,13 @@ def get_react_codegen_spec(package_json_file, folly_version: '2023.08.07.00', fa
"React-NativeModulesApple": [],
"glog": [],
"DoubleConversion": [],
}
}

if fabric_enabled
spec[:'dependencies'].merge!({
'React-graphics': [],
'React-rendererdebug': [],
'React-Fabric': [],
'React-debug': [],
'React-utils': [],
});
end
}
}

if hermes_enabled
spec[:'dependencies'].merge!({
Expand Down Expand Up @@ -313,7 +307,6 @@ def use_react_native_codegen_discovery!(
react_codegen_spec = codegen_utils.get_react_codegen_spec(
file_manager.join(relative_installation_root, react_native_path, "package.json"),
:folly_version => folly_version,
:fabric_enabled => fabric_enabled,
:hermes_enabled => hermes_enabled,
:script_phases => script_phases
)
Expand Down
12 changes: 3 additions & 9 deletions packages/react-native/scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def use_react_native! (

ReactNativePodsUtils.warn_if_not_on_arm64()

build_codegen!(prefix, relative_path_from_current)

# The Pods which should be included in all projects
pod 'FBLazyVector', :path => "#{prefix}/Libraries/FBLazyVector"
pod 'RCTRequired', :path => "#{prefix}/Libraries/Required"
Expand Down Expand Up @@ -174,15 +176,7 @@ def use_react_native! (
# 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.
setup_fabric!(:react_native_path => prefix)

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
setup_bridgeless!(:react_native_path => prefix, :use_hermes => hermes_enabled)

pods_to_update = LocalPodspecPatch.pods_to_update(:react_native_path => prefix)
if !pods_to_update.empty?
Expand Down

0 comments on commit 6b53205

Please sign in to comment.