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
This commit is contained in:
Riccardo Cipolleschi authored and Facebook GitHub Bot committed 2025-01-27 06:52:35 -08:00
1 parent e3def00d7a
commit f15094ef88
3 files changed
+12

No files matched your search

@@ -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,
@@ -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)
@@ -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