Skip to content

Commit 6b53205

Browse files
cipolleschifacebook-github-bot
authored andcommitted
Always install all the pods (facebook#41588)
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
1 parent a607692 commit 6b53205

File tree

5 files changed

+26
-72
lines changed

5 files changed

+26
-72
lines changed

packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -80,42 +80,33 @@ Pod::Spec.new do |s|
8080
add_dependency(s, "React-NativeModulesApple")
8181
add_dependency(s, "React-runtimescheduler")
8282
add_dependency(s, "React-RCTFabric", :framework_name => "RCTFabric")
83-
84-
if is_new_arch_enabled
85-
add_dependency(s, "React-RuntimeCore")
86-
add_dependency(s, "React-RuntimeApple")
87-
if use_hermes
88-
s.dependency "React-RuntimeHermes"
89-
end
90-
end
83+
add_dependency(s, "React-RuntimeCore")
84+
add_dependency(s, "React-RuntimeApple")
85+
add_dependency(s, "React-Fabric", :additional_framework_paths => ["react/renderer/components/view/platform/cxx"])
86+
add_dependency(s, "React-graphics", :additional_framework_paths => ["react/renderer/graphics/platform/ios"])
87+
add_dependency(s, "React-utils")
88+
add_dependency(s, "React-debug")
89+
add_dependency(s, "React-rendererdebug")
9190

9291
if use_hermes
9392
s.dependency "React-hermes"
93+
s.dependency "React-RuntimeHermes"
9494
else
9595
s.dependency "React-jsc"
9696
end
9797

98-
if is_new_arch_enabled
99-
add_dependency(s, "React-Fabric", :additional_framework_paths => ["react/renderer/components/view/platform/cxx"])
100-
add_dependency(s, "React-graphics", :additional_framework_paths => ["react/renderer/graphics/platform/ios"])
101-
add_dependency(s, "React-utils")
102-
add_dependency(s, "React-debug")
103-
add_dependency(s, "React-rendererdebug")
104-
105-
rel_path_from_pods_root_to_app = Pathname.new(ENV['APP_PATH']).relative_path_from(Pod::Config.instance.installation_root)
106-
rel_path_from_pods_to_app = Pathname.new(ENV['APP_PATH']).relative_path_from(File.join(Pod::Config.instance.installation_root, 'Pods'))
98+
rel_path_from_pods_root_to_app = Pathname.new(ENV['APP_PATH']).relative_path_from(Pod::Config.instance.installation_root)
99+
rel_path_from_pods_to_app = Pathname.new(ENV['APP_PATH']).relative_path_from(File.join(Pod::Config.instance.installation_root, 'Pods'))
107100

108-
109-
s.script_phases = {
110-
:name => "Generate Legacy Components Interop",
111-
:script => "
101+
s.script_phases = {
102+
:name => "Generate Legacy Components Interop",
103+
:script => "
112104
WITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"
113105
source $WITH_ENVIRONMENT
114106
${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
115-
",
116-
:execution_position => :before_compile,
117-
:input_files => ["#{rel_path_from_pods_root_to_app}/react-native.config.js"],
118-
:output_files => ["${REACT_NATIVE_PATH}/Libraries/AppDelegate/RCTLegacyInteropComponents.mm"],
119-
}
120-
end
107+
",
108+
:execution_position => :before_compile,
109+
:input_files => ["#{rel_path_from_pods_root_to_app}/react-native.config.js"],
110+
:output_files => ["${REACT_NATIVE_PATH}/Libraries/AppDelegate/RCTLegacyInteropComponents.mm"],
111+
}
121112
end

packages/react-native/scripts/cocoapods/__tests__/codegen_utils-test.rb

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -93,33 +93,13 @@ def testGenerateReactCodegenPodspec_whenItHasNotBeenAlreadyGenerated_generatesIt
9393
# ========================== #
9494
# Test - GetReactCodegenSpec #
9595
# ========================== #
96-
97-
def testGetReactCodegenSpec_whenFabricDisabledAndNoScriptPhases_generatesAPodspec
98-
# Arrange
99-
FileMock.files_to_read('package.json' => '{ "version": "99.98.97"}')
100-
101-
# Act
102-
podspec = CodegenUtils.new().get_react_codegen_spec(
103-
'package.json',
104-
:fabric_enabled => false,
105-
:hermes_enabled => true,
106-
:script_phases => nil,
107-
:file_manager => FileMock
108-
)
109-
110-
# Assert
111-
assert_equal(podspec, get_podspec_no_fabric_no_script())
112-
assert_equal(Pod::UI.collected_messages, [])
113-
end
114-
11596
def testGetReactCodegenSpec_whenFabricEnabledAndScriptPhases_generatesAPodspec
11697
# Arrange
11798
FileMock.files_to_read('package.json' => '{ "version": "99.98.97"}')
11899

119100
# Act
120101
podspec = CodegenUtils.new().get_react_codegen_spec(
121102
'package.json',
122-
:fabric_enabled => true,
123103
:hermes_enabled => true,
124104
:script_phases => "echo Test Script Phase",
125105
:file_manager => FileMock
@@ -138,7 +118,7 @@ def testGetReactCodegenSpec_whenUseFrameworksAndNewArch_generatesAPodspec
138118
# Act
139119
podspec = CodegenUtils.new().get_react_codegen_spec(
140120
'package.json',
141-
:fabric_enabled => true,
121+
142122
:hermes_enabled => true,
143123
:script_phases => nil,
144124
:file_manager => FileMock
@@ -380,11 +360,9 @@ def testUseReactCodegenDiscovery_whenParametersAreGood_executeCodegen
380360
:app_path => app_path,
381361
:config_file_dir => "",
382362
:config_key => "codegenConfig",
383-
:fabric_enabled => false,
384363
:react_native_path => "../node_modules/react-native"}
385364
])
386365
assert_equal(codegen_utils_mock.get_react_codegen_spec_params, [{
387-
:fabric_enabled => false,
388366
:folly_version=>"2023.08.07.00",
389367
:package_json_file => "#{app_path}/ios/../node_modules/react-native/package.json",
390368
:script_phases => "echo TestScript"

packages/react-native/scripts/cocoapods/__tests__/test_utils/CodegenUtilsMock.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,17 @@ def get_react_codegen_script_phases(
5858
)
5959
@get_react_codegen_script_phases_params.push({
6060
app_path: app_path,
61-
fabric_enabled: fabric_enabled,
6261
config_file_dir: config_file_dir,
6362
react_native_path: react_native_path,
6463
config_key: config_key
6564
})
6665
return @react_codegen_script_phases
6766
end
6867

69-
def get_react_codegen_spec(package_json_file, folly_version: '2023.08.07.00', fabric_enabled: false, hermes_enabled: true, script_phases: nil)
68+
def get_react_codegen_spec(package_json_file, folly_version: '2023.08.07.00', hermes_enabled: true, script_phases: nil)
7069
@get_react_codegen_spec_params.push({
7170
package_json_file: package_json_file,
7271
folly_version: folly_version,
73-
fabric_enabled: fabric_enabled,
7472
script_phases: script_phases
7573
})
7674
return @react_codegen_spec

packages/react-native/scripts/cocoapods/codegen_utils.rb

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,10 @@ def generate_react_codegen_podspec!(spec, codegen_output_dir, file_manager: File
6666
#
6767
# Parameters
6868
# - package_json_file: the path to the `package.json`, required to extract the proper React Native version
69-
# - fabric_enabled: whether fabric is enabled or not.
7069
# - hermes_enabled: whether hermes is enabled or not.
7170
# - script_phases: whether we want to add some build script phases or not.
7271
# - file_manager: a class that implements the `File` interface. Defaults to `File`, the Dependency can be injected for testing purposes.
73-
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)
72+
def get_react_codegen_spec(package_json_file, folly_version: '2023.08.07.00', hermes_enabled: true, script_phases: nil, file_manager: File)
7473
package = JSON.parse(file_manager.read(package_json_file))
7574
version = package['version']
7675
new_arch_disabled = ENV['RCT_NEW_ARCH_ENABLED'] != "1"
@@ -136,18 +135,13 @@ def get_react_codegen_spec(package_json_file, folly_version: '2023.08.07.00', fa
136135
"React-NativeModulesApple": [],
137136
"glog": [],
138137
"DoubleConversion": [],
139-
}
140-
}
141-
142-
if fabric_enabled
143-
spec[:'dependencies'].merge!({
144138
'React-graphics': [],
145139
'React-rendererdebug': [],
146140
'React-Fabric': [],
147141
'React-debug': [],
148142
'React-utils': [],
149-
});
150-
end
143+
}
144+
}
151145

152146
if hermes_enabled
153147
spec[:'dependencies'].merge!({
@@ -313,7 +307,6 @@ def use_react_native_codegen_discovery!(
313307
react_codegen_spec = codegen_utils.get_react_codegen_spec(
314308
file_manager.join(relative_installation_root, react_native_path, "package.json"),
315309
:folly_version => folly_version,
316-
:fabric_enabled => fabric_enabled,
317310
:hermes_enabled => hermes_enabled,
318311
:script_phases => script_phases
319312
)

packages/react-native/scripts/react_native_pods.rb

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ def use_react_native! (
103103

104104
ReactNativePodsUtils.warn_if_not_on_arm64()
105105

106+
build_codegen!(prefix, relative_path_from_current)
107+
106108
# The Pods which should be included in all projects
107109
pod 'FBLazyVector', :path => "#{prefix}/Libraries/FBLazyVector"
108110
pod 'RCTRequired', :path => "#{prefix}/Libraries/Required"
@@ -174,15 +176,7 @@ def use_react_native! (
174176
# If the New Arch is turned off, we will use the Old Renderer, though.
175177
# RNTester always installed Fabric, this change is required to make the template work.
176178
setup_fabric!(:react_native_path => prefix)
177-
178-
if !fabric_enabled
179-
relative_installation_root = Pod::Config.instance.installation_root.relative_path_from(Pathname.pwd)
180-
build_codegen!(prefix, relative_installation_root)
181-
end
182-
183-
if NewArchitectureHelper.new_arch_enabled
184-
setup_bridgeless!(:react_native_path => prefix, :use_hermes => hermes_enabled)
185-
end
179+
setup_bridgeless!(:react_native_path => prefix, :use_hermes => hermes_enabled)
186180

187181
pods_to_update = LocalPodspecPatch.pods_to_update(:react_native_path => prefix)
188182
if !pods_to_update.empty?

0 commit comments

Comments
 (0)