-
Notifications
You must be signed in to change notification settings - Fork 25k
Move use_flipper logic inside use_react_native and simplify the Flipper dependencies logic
#33882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c05cb76
c3d8783
fdd92c8
387d626
0bc843f
7be8a3e
3e9545f
543f1d8
b2d71d5
b3a0bc6
dc8ad2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,10 +22,8 @@ | |||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||
| # @parameter production: a boolean that indicates whether we are in production or not. | ||||||||||||||||||||||||||||||
| # @parameter pathToReactNative: the path to the React Native installation | ||||||||||||||||||||||||||||||
| def install_flipper_dependencies(production, pathToReactNative) | ||||||||||||||||||||||||||||||
| unless production | ||||||||||||||||||||||||||||||
| pod 'React-Core/DevSupport', :path => "#{pathToReactNative}/" | ||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||
| def install_flipper_dependencies(pathToReactNative) | ||||||||||||||||||||||||||||||
| pod 'React-Core/DevSupport', :path => "#{pathToReactNative}/" | ||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -92,3 +90,23 @@ def flipper_post_install(installer) | |||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| class FlipperConfiguration | ||||||||||||||||||||||||||||||
| attr_reader :flipper_enabled | ||||||||||||||||||||||||||||||
| attr_reader :configurations | ||||||||||||||||||||||||||||||
| attr_reader :versions | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| def initialize(flipper_enabled, configurations, versions) | ||||||||||||||||||||||||||||||
| @flipper_enabled = flipper_enabled | ||||||||||||||||||||||||||||||
| @configurations = configurations | ||||||||||||||||||||||||||||||
| @versions = versions | ||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| def self.enabled(configurations = ["Debug"], versions = {}) | ||||||||||||||||||||||||||||||
| return FlipperConfiguration.new(true, configurations, versions) | ||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| def self.disabled | ||||||||||||||||||||||||||||||
| return FlipperConfiguration.new(false, [], {}) | ||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||
|
Comment on lines
+105
to
+111
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: In Ruby, the last statement is always returned so we can drop
Suggested change
|
||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,8 @@ def use_react_native! (options={}) | |
| # Include Hermes dependencies | ||
| hermes_enabled = options[:hermes_enabled] ||= false | ||
|
|
||
| flipper_configuration = options[:flipper_configuration] ||= FlipperConfiguration.disabled | ||
|
|
||
| if `/usr/sbin/sysctl -n hw.optional.arm64 2>&1`.to_i == 1 && !RUBY_PLATFORM.include?('arm64') | ||
| Pod::UI.warn 'Do not use "pod install" from inside Rosetta2 (x86_64 emulation on arm64).' | ||
| Pod::UI.warn ' - Emulated x86_64 is slower than native arm64' | ||
|
|
@@ -62,8 +64,6 @@ def use_react_native! (options={}) | |
| pod 'React-RCTVibration', :path => "#{prefix}/Libraries/Vibration" | ||
| pod 'React-Core/RCTWebSocket', :path => "#{prefix}/" | ||
|
|
||
| install_flipper_dependencies(production, prefix) | ||
|
|
||
| pod 'React-bridging', :path => "#{prefix}/ReactCommon/react/bridging" | ||
| pod 'React-cxxreact', :path => "#{prefix}/ReactCommon/cxxreact" | ||
| pod 'React-jsi', :path => "#{prefix}/ReactCommon/jsi" | ||
|
|
@@ -128,6 +128,11 @@ def use_react_native! (options={}) | |
|
|
||
| end | ||
|
|
||
| if flipper_configuration.flipper_enabled && !production | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a temporary workaround that should fix #33764
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Correct me if I'm wrong, but it used to have to call it anyway, passing I would also specify, perhaps also adding some doc, that it's still the case. When a user wants to build for release, it has to run
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is correct, however if there wasn't the mentioned issue we could only rely on CocoaPods' configurations logic to do esclude Flipper from production (it would anyway compile flipper but wouldn't copy it) and remove the production flag.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a comment about that here? I think this can be easily missed since it's such a weird quirk of CocoaPods.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, sorry I missed this comment, will make another PR to fix those two comments as well
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opened #33902 |
||
| install_flipper_dependencies(prefix) | ||
| use_flipper_pods(flipper_configuration.versions, :configurations => flipper_configuration.configurations) | ||
| end | ||
|
|
||
| pods_to_update = LocalPodspecPatch.pods_to_update(options) | ||
| if !pods_to_update.empty? | ||
| if Pod::Lockfile.public_instance_methods.include?(:detect_changes_with_podfile) | ||
|
|
@@ -142,6 +147,7 @@ def get_default_flags() | |
| flags = { | ||
| :fabric_enabled => false, | ||
| :hermes_enabled => false, | ||
| :flipper_configuration => FlipperConfiguration.disabled | ||
| } | ||
|
|
||
| if ENV['RCT_NEW_ARCH_ENABLED'] == '1' | ||
|
|
@@ -153,6 +159,7 @@ def get_default_flags() | |
| end | ||
|
|
||
| def use_flipper!(versions = {}, configurations: ['Debug']) | ||
| Pod::UI.warn "use_flipper is deprecated, use the flipper_configuration option in the use_react_native function" | ||
| use_flipper_pods(versions, :configurations => configurations) | ||
| end | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,11 @@ target 'HelloWorld' do | |
| # You can enabled/disable it manually by replacing `flags[:hermes_enabled]` with `true` or `false`. | ||
| :hermes_enabled => flags[:hermes_enabled], | ||
| :fabric_enabled => flags[:fabric_enabled], | ||
| # Enables Flipper. | ||
| # | ||
| # Note that if you have use_frameworks! enabled, Flipper will not work and | ||
| # you should disable the next line. | ||
| :flipper_configuration => FlipperConfiguration.enabled, | ||
| # An absolute path to your application root. | ||
| :app_path => "#{Pod::Config.instance.installation_root}/.." | ||
| ) | ||
|
|
@@ -25,12 +30,6 @@ target 'HelloWorld' do | |
| # Pods for testing | ||
| end | ||
|
|
||
| # Enables Flipper. | ||
| # | ||
| # Note that if you have use_frameworks! enabled, Flipper will not work and | ||
| # you should disable the next line. | ||
| use_flipper!() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a small heads up: shouldn't we deprecate What happens to a user that is doing?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea is that it won't work, the function def use_flipper!(versions = {}, configurations: ['Debug'])
Pod::UI.warn "use_flipper is deprecated, use the flipper_configuration option in the use_react_native function"
use_flipper_pods(versions, :configurations => configurations)
end
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup that makes total sense 👍 |
||
|
|
||
| post_install do |installer| | ||
| react_native_post_install(installer) | ||
| __apply_Xcode_12_5_M1_post_install_workaround(installer) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.