[fix] backport FlipperConfiguration from main (#34098)

This commit is contained in:
Riccardo
2022-07-07 08:24:22 +02:00
committed by GitHub
parent 587eb4ed13
commit 23accbf58d
5 changed files with 52 additions and 13 deletions
+31
View File
@@ -0,0 +1,31 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# Helper class to configure flipper
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 = {})
FlipperConfiguration.new(true, configurations, versions)
end
def self.disabled
FlipperConfiguration.new(false, [], {})
end
def == (other)
return @flipper_enabled == other.flipper_enabled &&
@configurations == other.configurations &&
@versions == other.versions
end
end
+10 -1
View File
@@ -6,6 +6,7 @@
require 'json'
require 'open3'
require 'pathname'
require_relative './cocoapods/FlipperConfiguration.rb'
require_relative './react_native_pods_utils/script_phases.rb'
$CODEGEN_OUTPUT_DIR = 'build/generated/ios'
@@ -29,6 +30,9 @@ def use_react_native! (options={})
# Include Hermes dependencies
hermes_enabled = options[:hermes_enabled] ||= false
# Extract Flipper configuration
flipper_configuration = options[:flipper_configuration] ||= FlipperConfiguration.disabled
# Codegen Discovery is required when enabling new architecture.
if ENV['RCT_NEW_ARCH_ENABLED'] == '1'
Pod::UI.puts 'Setting USE_CODEGEN_DISCOVERY=1'
@@ -61,8 +65,13 @@ def use_react_native! (options={})
pod 'React-RCTVibration', :path => "#{prefix}/Libraries/Vibration"
pod 'React-Core/RCTWebSocket', :path => "#{prefix}/"
unless production
# CocoaPods `configurations` option ensures that the target is copied only for the specified configurations,
# but those dependencies are still built.
# Flipper doesn't currently compile for release https://github.com/facebook/react-native/issues/33764
# Setting the production flag to true when build for production make sure that we don't install Flipper in the app in the first place.
if flipper_configuration.flipper_enabled && !production
pod 'React-Core/DevSupport', :path => "#{prefix}/"
use_flipper!(flipper_configuration.versions, :configurations => flipper_configuration.configurations)
end
pod 'React-bridging', :path => "#{prefix}/ReactCommon"