diff --git a/packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec b/packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec index d542966ee1ac94..ad7fee87cfe967 100644 --- a/packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec +++ b/packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec @@ -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 diff --git a/packages/react-native/scripts/cocoapods/__tests__/codegen_utils-test.rb b/packages/react-native/scripts/cocoapods/__tests__/codegen_utils-test.rb index e485b89c21d1b8..e635db3f708efd 100644 --- a/packages/react-native/scripts/cocoapods/__tests__/codegen_utils-test.rb +++ b/packages/react-native/scripts/cocoapods/__tests__/codegen_utils-test.rb @@ -93,25 +93,6 @@ 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"}') @@ -119,7 +100,6 @@ def testGetReactCodegenSpec_whenFabricEnabledAndScriptPhases_generatesAPodspec # 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 @@ -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 @@ -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" diff --git a/packages/react-native/scripts/cocoapods/__tests__/test_utils/CodegenUtilsMock.rb b/packages/react-native/scripts/cocoapods/__tests__/test_utils/CodegenUtilsMock.rb index e6b4174a17e043..4c0cc8d6cbeaa3 100644 --- a/packages/react-native/scripts/cocoapods/__tests__/test_utils/CodegenUtilsMock.rb +++ b/packages/react-native/scripts/cocoapods/__tests__/test_utils/CodegenUtilsMock.rb @@ -58,7 +58,6 @@ 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 @@ -66,11 +65,10 @@ def get_react_codegen_script_phases( 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 diff --git a/packages/react-native/scripts/cocoapods/codegen_utils.rb b/packages/react-native/scripts/cocoapods/codegen_utils.rb index 71018f2b7ee754..951adaaa2572cc 100644 --- a/packages/react-native/scripts/cocoapods/codegen_utils.rb +++ b/packages/react-native/scripts/cocoapods/codegen_utils.rb @@ -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" @@ -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!({ @@ -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 ) diff --git a/packages/react-native/scripts/react_native_pods.rb b/packages/react-native/scripts/react_native_pods.rb index 472a563baddc05..f0a0ba120cfcba 100644 --- a/packages/react-native/scripts/react_native_pods.rb +++ b/packages/react-native/scripts/react_native_pods.rb @@ -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" @@ -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?