Skip to content

Commit 79a37e5

Browse files
Riccardo Cipolleschifacebook-github-bot
authored andcommitted
Destructure use_react_native! parameters and doc (#34177)
Summary: Pull Request resolved: #34177 This Diff destructures the parameters of the use_react_native! function. It does that in a backward compatible way, so we there should be no disruptions. It also adds documentation to the various public method we want to export to our users. ## Changelog [iOS][Changed] - Destruct use_reactnative parameters and ad ddocumentation Reviewed By: cortinico Differential Revision: D37787365 fbshipit-source-id: 27f9030db2e8c6c66b9548b4c1287eb8165ae5fc
1 parent 7d069b2 commit 79a37e5

File tree

1 file changed

+37
-20
lines changed

1 file changed

+37
-20
lines changed

scripts/react_native_pods.rb

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,32 @@
2222

2323
$START_TIME = Time.now.to_i
2424

25-
def use_react_native! (options={})
25+
# Function that setup all the react native dependencies
26+
27+
# Parameters
28+
# - path: path to react_native installation.
29+
# - fabric_enabled: whether fabric should be enabled or not.
30+
# - new_arch_enabled: whether the new architecture should be enabled or not.
31+
# - production: whether the dependencies must be installed to target a Debug or a Release build.
32+
# - hermes_enabled: whether Hermes should be enabled or not.
33+
# - flipper_configuration: The configuration to use for flipper.
34+
# - app_path: path to the React Native app. Required by the New Architecture.
35+
# - config_file_dir: directory of the `package.json` file, required by the New Architecture.
36+
def use_react_native! (
37+
path: "../node_modules/react-native",
38+
fabric_enabled: false,
39+
new_arch_enabled: ENV['RCT_NEW_ARCH_ENABLED'] == '1',
40+
production: false,
41+
hermes_enabled: true,
42+
flipper_configuration: FlipperConfiguration.disabled,
43+
app_path: '..',
44+
config_file_dir: '')
45+
46+
prefix = path
47+
2648
# The version of folly that must be used
2749
folly_version = '2021.07.22.00'
2850

29-
# The prefix to react-native
30-
prefix = options[:path] ||= "../node_modules/react-native"
31-
32-
# Include Fabric dependencies
33-
fabric_enabled = options[:fabric_enabled] ||= false
34-
35-
# New arch enabled
36-
new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
37-
38-
# Include DevSupport dependency
39-
production = options[:production] ||= false
40-
41-
# Include Hermes dependencies
42-
hermes_enabled = options[:hermes_enabled] != nil ? options[:hermes_enabled] : true
43-
44-
flipper_configuration = options[:flipper_configuration] ||= FlipperConfiguration.disabled
45-
4651
ReactNativePodsUtils.warn_if_not_on_arm64()
4752

4853
# The Pods which should be included in all projects
@@ -82,8 +87,8 @@ def use_react_native! (options={})
8287
pod 'RCT-Folly', :podspec => "#{prefix}/third-party-podspecs/RCT-Folly.podspec", :modular_headers => true
8388

8489
run_codegen!(
85-
options[:app_path],
86-
options[:config_file_dir],
90+
app_path,
91+
config_file_dir,
8792
:new_arch_enabled => new_arch_enabled,
8893
:disable_codegen => ENV['DISABLE_CODEGEN'] == '1',
8994
:react_native_path => prefix,
@@ -121,15 +126,27 @@ def use_react_native! (options={})
121126
end
122127
end
123128

129+
# It returns the default flags.
124130
def get_default_flags()
125131
return ReactNativePodsUtils.get_default_flags()
126132
end
127133

134+
# It installs the flipper dependencies into the project.
135+
#
136+
# Parameters
137+
# - versions: a dictionary of Flipper Library -> Versions that can be used to customize which version of Flipper to install.
138+
# - configurations: an array of configuration where to install the dependencies.
128139
def use_flipper!(versions = {}, configurations: ['Debug'])
129140
Pod::UI.warn "use_flipper is deprecated, use the flipper_configuration option in the use_react_native function"
130141
use_flipper_pods(versions, :configurations => configurations)
131142
end
132143

144+
# Function that executes after React Native has been installed to configure some flags and build settings.
145+
#
146+
# Parameters
147+
# - installer: the Cocoapod object that allows to customize the project.
148+
# - react_native_path: path to React Native.
149+
# - mac_catalyst_enabled: whether we are running the Pod on a Mac Catalyst project or not.
133150
def react_native_post_install(installer, react_native_path = "../node_modules/react-native", mac_catalyst_enabled: false)
134151
ReactNativePodsUtils.apply_mac_catalyst_patches(installer) if mac_catalyst_enabled
135152

0 commit comments

Comments
 (0)