mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
[fix] backport FlipperConfiguration from main (#34098)
This commit is contained in:
@@ -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
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user