From daa99fe5e7d3b4fc634513ae8b3d954c7b40eaa4 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Wed, 14 Jun 2023 10:10:16 -0700 Subject: [PATCH] Cleanup, remove the PRODUCTION flag (#37882) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37882 After some progressive changes, we can finally remove the PRODUCTION flag from the codebase. ## Changelog: [iOS][Removed] - Remove PRODUCTION flag from iOS build logic Reviewed By: cortinico, dmytrorykun Differential Revision: D46726208 fbshipit-source-id: 407268779be8de32c5a6c15ba220a60b7cb9ced7 --- .circleci/config.yml | 4 ---- .../ReactCommon/hermes/React-hermes.podspec | 2 -- .../scripts/cocoapods/__tests__/flipper-test.rb | 1 + packages/react-native/scripts/cocoapods/flipper.rb | 5 ++--- packages/react-native/scripts/react_native_pods.rb | 13 +++++-------- packages/rn-tester/Podfile | 2 +- 6 files changed, 9 insertions(+), 18 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 933e062f9dbcae..879715c2e92bc0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -886,10 +886,6 @@ jobs: command: | cd /tmp/$PROJECT_NAME/ios - if [[ << parameters.flavor >> == "Release" ]]; then - export PRODUCTION=1 - fi - if [[ << parameters.architecture >> == "NewArch" ]]; then export RCT_NEW_ARCH_ENABLED=1 fi diff --git a/packages/react-native/ReactCommon/hermes/React-hermes.podspec b/packages/react-native/ReactCommon/hermes/React-hermes.podspec index 72f16d96d388d7..300d1571ad931a 100644 --- a/packages/react-native/ReactCommon/hermes/React-hermes.podspec +++ b/packages/react-native/ReactCommon/hermes/React-hermes.podspec @@ -5,8 +5,6 @@ require "json" -# Whether Hermes is built for Release or Debug is determined by the PRODUCTION envvar. - # package.json package = JSON.parse(File.read(File.join(__dir__, "..", "..", "package.json"))) version = package['version'] diff --git a/packages/react-native/scripts/cocoapods/__tests__/flipper-test.rb b/packages/react-native/scripts/cocoapods/__tests__/flipper-test.rb index 2c0659ecc4cd13..905c0af2ec938f 100644 --- a/packages/react-native/scripts/cocoapods/__tests__/flipper-test.rb +++ b/packages/react-native/scripts/cocoapods/__tests__/flipper-test.rb @@ -23,6 +23,7 @@ def test_installFlipperDependencies_installDependencies # Assert assert_equal($podInvocationCount, 1) assert_equal($podInvocation['React-Core/DevSupport'][:path], "../../" ) + assert_equal($podInvocation['React-Core/DevSupport'][:configurations], ["Debug"] ) end # ======================= # diff --git a/packages/react-native/scripts/cocoapods/flipper.rb b/packages/react-native/scripts/cocoapods/flipper.rb index 73371c1df603b1..f41ed7d7893eb9 100644 --- a/packages/react-native/scripts/cocoapods/flipper.rb +++ b/packages/react-native/scripts/cocoapods/flipper.rb @@ -19,10 +19,9 @@ # This function installs the `React-Core/DevSupport` subpods # when the dependencies are installed for a non production app. # -# @parameter production: a boolean that indicates whether we are in production or not. # @parameter pathToReactNative: the path to the React Native installation -def install_flipper_dependencies(pathToReactNative) - pod 'React-Core/DevSupport', :path => "#{pathToReactNative}/" +def install_flipper_dependencies(pathToReactNative, configurations: ["Debug"]) + pod 'React-Core/DevSupport', :path => "#{pathToReactNative}/", :configurations => configurations end diff --git a/packages/react-native/scripts/react_native_pods.rb b/packages/react-native/scripts/react_native_pods.rb index cee3065b2ef64e..440a9e0577f950 100644 --- a/packages/react-native/scripts/react_native_pods.rb +++ b/packages/react-native/scripts/react_native_pods.rb @@ -57,7 +57,7 @@ def prepare_react_native_project! # - path: path to react_native installation. # - fabric_enabled: whether fabric should be enabled or not. # - new_arch_enabled: whether the new architecture should be enabled or not. -# - production: whether the dependencies must be installed to target a Debug or a Release build. +# - :production [DEPRECATED] whether the dependencies must be installed to target a Debug or a Release build. # - hermes_enabled: whether Hermes should be enabled or not. # - flipper_configuration: The configuration to use for flipper. # - app_path: path to the React Native app. Required by the New Architecture. @@ -67,7 +67,7 @@ def use_react_native! ( path: "../node_modules/react-native", fabric_enabled: false, new_arch_enabled: ENV['RCT_NEW_ARCH_ENABLED'] == '1', - production: ENV['PRODUCTION'] == '1', + production: false, # deprecated hermes_enabled: ENV['USE_HERMES'] && ENV['USE_HERMES'] == '0' ? false : true, flipper_configuration: FlipperConfiguration.disabled, app_path: '..', @@ -164,12 +164,9 @@ def use_react_native! ( build_codegen!(prefix, relative_installation_root) end - # CocoaPods `configurations` option ensures that the target is copied only for the specified configurations, - # but those dependencies are still built. - # Flipper doesn't currently compile for release https://github.com/facebook/react-native/issues/33764 - # Setting the production flag to true when build for production make sure that we don't install Flipper in the app in the first place. - if flipper_configuration.flipper_enabled && !production - install_flipper_dependencies(prefix) + # Flipper now build in Release mode but it is not linked to the Release binary (as specified by the Configuration option) + if flipper_configuration.flipper_enabled + install_flipper_dependencies(prefix, :configurations => flipper_configuration.configurations) use_flipper_pods(flipper_configuration.versions, :configurations => flipper_configuration.configurations) end diff --git a/packages/rn-tester/Podfile b/packages/rn-tester/Podfile index e4e35975def76c..cf6b7f05d24d6d 100644 --- a/packages/rn-tester/Podfile +++ b/packages/rn-tester/Podfile @@ -38,7 +38,7 @@ def pods(target_name, options = {}, use_flipper: !IN_CI && !USE_FRAMEWORKS) flipper_configuration: use_flipper ? FlipperConfiguration.enabled : FlipperConfiguration.disabled, app_path: "#{Dir.pwd}", config_file_dir: "#{Dir.pwd}/node_modules", - production: !ENV['PRODUCTION'].nil?, + production: false, #deprecated ios_folder: '.', ) pod 'ReactCommon-Samples', :path => "#{@prefix_path}/ReactCommon/react/nativemodule/samples"