From f15094ef880218a0517863e6cf7d11247be66bfb Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Mon, 27 Jan 2025 06:52:35 -0800 Subject: [PATCH] Stop running Codegen on Pod install when a flag is passed (#48961) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48961 One of Cocoapods responsibility is to run Codegen while creating the Xcode workspace. Moving away from Cocoapods, this is a step we need to move to a different place. This change let us to disable running codegen at cocoapods time when we pass the `RCT_SKIP_CODEGEN=1` or when we pass the `RCT_IGNORE_PODS_DEPRECATION=1` flag calling pod install. When calling `pod install` with `RCT_IGNORE_PODS_DEPRECATION` we are either: * using one of the Scripts provided by Expo or by the Community CLI *or* * we are preparing the project using the legacy mode and, therefore, we want to keep running codegen. ## Changelog [iOS][Changed] - Stop running codegen when running pod install Reviewed By: cortinico Differential Revision: D68704604 fbshipit-source-id: 252e90544886c3dbfd7eff38c344dd4784a0af38 --- packages/react-native/scripts/cocoapods/codegen.rb | 4 ++++ packages/react-native/scripts/cocoapods/codegen_utils.rb | 4 ++++ packages/react-native/scripts/react_native_pods.rb | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/packages/react-native/scripts/cocoapods/codegen.rb b/packages/react-native/scripts/cocoapods/codegen.rb index cd76a0a7540..a19d151e17b 100644 --- a/packages/react-native/scripts/cocoapods/codegen.rb +++ b/packages/react-native/scripts/cocoapods/codegen.rb @@ -21,6 +21,10 @@ def run_codegen!( codegen_utils: CodegenUtils.new() ) + if ENV["RCT_SKIP_CODEGEN"] == "1" + return + end + codegen_utils.use_react_native_codegen_discovery!( disable_codegen, app_path, diff --git a/packages/react-native/scripts/cocoapods/codegen_utils.rb b/packages/react-native/scripts/cocoapods/codegen_utils.rb index 6f62e8c75ae..3ce12e28ebc 100644 --- a/packages/react-native/scripts/cocoapods/codegen_utils.rb +++ b/packages/react-native/scripts/cocoapods/codegen_utils.rb @@ -76,6 +76,10 @@ class CodegenUtils end def self.clean_up_build_folder(rn_path, codegen_dir, dir_manager: Dir, file_manager: File) + if ENV["RCT_SKIP_CODEGEN"] == "1" + return + end + return if CodegenUtils.cleanup_done() CodegenUtils.set_cleanup_done(true) diff --git a/packages/react-native/scripts/react_native_pods.rb b/packages/react-native/scripts/react_native_pods.rb index 201396d90d0..4f1c53b0289 100644 --- a/packages/react-native/scripts/react_native_pods.rb +++ b/packages/react-native/scripts/react_native_pods.rb @@ -73,6 +73,10 @@ def use_react_native! ( ENV['APP_PATH'] = app_path ENV['REACT_NATIVE_PATH'] = path + # We set RCT_SKIP_CODEGEN to true, if the user wants to skip the running Codegen step from Cocoapods. + # This is needed as part of our migration away from cocoapods + ENV['RCT_SKIP_CODEGEN'] = ENV['RCT_SKIP_CODEGEN'] == '1' || ENV['RCT_IGNORE_PODS_DEPRECATION'] == '1' ? '1' : '0' + ReactNativePodsUtils.check_minimum_required_xcode() # Current target definition is provided by Cocoapods and it refers to the target