Skip to content

Commit 24e07bc

Browse files
sota000facebook-github-bot
authored andcommitted
Move use_react_native_codegen_discovery to use_react_native! (#32749)
Summary: Pull Request resolved: #32749 Changelog: [Internal] Move the use_react_native_codegen_discovery call to use_react_native. Found out that pre_install doesn't get invoked until all podspecs are read. This wouldn't work because I want use_react_native_codegen_discovery to generate React-Codgen podspecs. I also think it's better to have less logic in Podfiles as it's hard to update once users set it up. Reviewed By: cortinico Differential Revision: D33054318 fbshipit-source-id: 6d62be454610c8a1d55988fe376ee3f187510a36
1 parent 4fb49cd commit 24e07bc

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

packages/rn-tester/Podfile

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,18 @@ def pods(options = {})
2626

2727
prefix_path = "../.."
2828

29-
if options[:use_codegen_discovery]
30-
Pod::UI.puts "[Codegen] Building target with codegen library discovery enabled."
31-
pre_install do |installer|
32-
use_react_native_codegen_discovery!({
33-
react_native_path: prefix_path,
34-
app_path: "#{Dir.pwd}",
35-
fabric_enabled: fabric_enabled,
36-
config_file_dir: "#{Dir.pwd}/node_modules",
37-
})
38-
end
29+
if ENV['USE_CODEGEN_DISCOVERY'] == '1'
3930
# Custom fabric component is only supported when using codegen discovery.
4031
pod 'MyNativeView', :path => "NativeComponentExample"
4132
end
4233

43-
use_react_native!(path: prefix_path, fabric_enabled: fabric_enabled, hermes_enabled: ENV['USE_HERMES'] == '1')
34+
use_react_native!(
35+
path: prefix_path,
36+
fabric_enabled: fabric_enabled,
37+
hermes_enabled: ENV['USE_HERMES'] == '1',
38+
app_path: "#{Dir.pwd}",
39+
config_file_dir: "#{Dir.pwd}/node_modules",
40+
)
4441
pod 'ReactCommon/turbomodule/samples', :path => "#{prefix_path}/ReactCommon"
4542

4643
# Additional Pods which aren't included in the default Podfile
@@ -53,7 +50,7 @@ def pods(options = {})
5350
end
5451

5552
target 'RNTester' do
56-
pods({ :use_codegen_discovery => ENV['USE_CODEGEN_DISCOVERY'] == '1' })
53+
pods()
5754
if !USE_FRAMEWORKS
5855
use_flipper!
5956
end

scripts/react_native_pods.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,19 @@ def use_react_native! (options={})
6868
pod 'boost', :podspec => "#{prefix}/third-party-podspecs/boost.podspec"
6969
pod 'RCT-Folly', :podspec => "#{prefix}/third-party-podspecs/RCT-Folly.podspec"
7070

71+
if ENV['USE_CODEGEN_DISCOVERY'] == '1'
72+
Pod::UI.puts "[Codegen] Building target with codegen library discovery enabled."
73+
# TODO: Make sure this is run only once per execution.
74+
app_path = options[:app_path]
75+
config_file_dir = options[:config_file_dir]
76+
use_react_native_codegen_discovery!({
77+
react_native_path: prefix,
78+
app_path: app_path,
79+
fabric_enabled: fabric_enabled,
80+
config_file_dir: config_file_dir,
81+
})
82+
end
83+
7184
# Generate a podspec file for generated files.
7285
temp_podinfo = generate_temp_pod_spec_for_codegen!(fabric_enabled)
7386
pod temp_podinfo['spec']['name'], :path => temp_podinfo['path']
@@ -354,6 +367,7 @@ def use_react_native_codegen_discovery!(options={})
354367
Pod::UI.puts out;
355368
else
356369
Pod::UI.warn '[Codegen] error: no app_path was provided'
370+
Pod::UI.warn '[Codegen] If you are calling use_react_native_codegen_discovery! in your Podfile, please remove the call and pass `app_path` and/or `config_file_dir` to `use_react_native!`.'
357371
exit 1
358372
end
359373
end

0 commit comments

Comments
 (0)