|
22 | 22 |
|
23 | 23 | $START_TIME = Time.now.to_i
|
24 | 24 |
|
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 | + |
26 | 48 | # The version of folly that must be used
|
27 | 49 | folly_version = '2021.07.22.00'
|
28 | 50 |
|
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 |
| - |
46 | 51 | ReactNativePodsUtils.warn_if_not_on_arm64()
|
47 | 52 |
|
48 | 53 | # The Pods which should be included in all projects
|
@@ -82,8 +87,8 @@ def use_react_native! (options={})
|
82 | 87 | pod 'RCT-Folly', :podspec => "#{prefix}/third-party-podspecs/RCT-Folly.podspec", :modular_headers => true
|
83 | 88 |
|
84 | 89 | run_codegen!(
|
85 |
| - options[:app_path], |
86 |
| - options[:config_file_dir], |
| 90 | + app_path, |
| 91 | + config_file_dir, |
87 | 92 | :new_arch_enabled => new_arch_enabled,
|
88 | 93 | :disable_codegen => ENV['DISABLE_CODEGEN'] == '1',
|
89 | 94 | :react_native_path => prefix,
|
@@ -121,15 +126,27 @@ def use_react_native! (options={})
|
121 | 126 | end
|
122 | 127 | end
|
123 | 128 |
|
| 129 | +# It returns the default flags. |
124 | 130 | def get_default_flags()
|
125 | 131 | return ReactNativePodsUtils.get_default_flags()
|
126 | 132 | end
|
127 | 133 |
|
| 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. |
128 | 139 | def use_flipper!(versions = {}, configurations: ['Debug'])
|
129 | 140 | Pod::UI.warn "use_flipper is deprecated, use the flipper_configuration option in the use_react_native function"
|
130 | 141 | use_flipper_pods(versions, :configurations => configurations)
|
131 | 142 | end
|
132 | 143 |
|
| 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. |
133 | 150 | def react_native_post_install(installer, react_native_path = "../node_modules/react-native", mac_catalyst_enabled: false)
|
134 | 151 | ReactNativePodsUtils.apply_mac_catalyst_patches(installer) if mac_catalyst_enabled
|
135 | 152 |
|
|
0 commit comments