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:
+2
-1
@@ -56,6 +56,7 @@
|
||||
"scripts/react_native_pods_utils/script_phases.rb",
|
||||
"scripts/react_native_pods_utils/script_phases.sh",
|
||||
"scripts/react_native_pods.rb",
|
||||
"scripts/cocoapods",
|
||||
"scripts/react-native-xcode.sh",
|
||||
"sdks/.hermesversion",
|
||||
"sdks/hermes-engine",
|
||||
@@ -188,4 +189,4 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ platform :ios, '12.4'
|
||||
install! 'cocoapods', :deterministic_uuids => false
|
||||
|
||||
USE_FRAMEWORKS = ENV['USE_FRAMEWORKS'] == '1'
|
||||
IN_CI = ENV['CI'] == 'true'
|
||||
|
||||
@prefix_path = "../.."
|
||||
|
||||
if USE_FRAMEWORKS
|
||||
@@ -15,7 +17,7 @@ if USE_FRAMEWORKS
|
||||
use_frameworks!
|
||||
end
|
||||
|
||||
def pods(options = {})
|
||||
def pods(options = {}, use_flipper: false)
|
||||
project 'RNTesterPods.xcodeproj'
|
||||
|
||||
fabric_enabled = true
|
||||
@@ -31,6 +33,7 @@ def pods(options = {})
|
||||
path: @prefix_path,
|
||||
fabric_enabled: fabric_enabled,
|
||||
hermes_enabled: hermes_enabled,
|
||||
flipper_configuration: use_flipper ? FlipperConfiguration.enabled : FlipperConfiguration.disabled,
|
||||
app_path: "#{Dir.pwd}",
|
||||
config_file_dir: "#{Dir.pwd}/node_modules",
|
||||
)
|
||||
@@ -46,10 +49,7 @@ def pods(options = {})
|
||||
end
|
||||
|
||||
target 'RNTester' do
|
||||
pods()
|
||||
if !USE_FRAMEWORKS
|
||||
use_flipper!
|
||||
end
|
||||
pods({}, :use_flipper => !IN_CI && !USE_FRAMEWORKS)
|
||||
end
|
||||
|
||||
target 'RNTesterUnitTests' do
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -4,6 +4,8 @@ require_relative '../node_modules/@react-native-community/cli-platform-ios/nativ
|
||||
platform :ios, '12.4'
|
||||
install! 'cocoapods', :deterministic_uuids => false
|
||||
|
||||
production = ENV["PRODUCTION"] == "1"
|
||||
|
||||
target 'HelloWorld' do
|
||||
config = use_native_modules!
|
||||
|
||||
@@ -13,8 +15,10 @@ target 'HelloWorld' do
|
||||
use_react_native!(
|
||||
:path => config[:reactNativePath],
|
||||
# to enable hermes on iOS, change `false` to `true` and then install pods
|
||||
:production => production,
|
||||
:hermes_enabled => flags[:hermes_enabled],
|
||||
:fabric_enabled => flags[:fabric_enabled],
|
||||
:flipper_configuration => FlipperConfiguration.enabled,
|
||||
# An absolute path to your application root.
|
||||
:app_path => "#{Pod::Config.instance.installation_root}/.."
|
||||
)
|
||||
@@ -24,12 +28,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!()
|
||||
|
||||
post_install do |installer|
|
||||
react_native_post_install(installer)
|
||||
__apply_Xcode_12_5_M1_post_install_workaround(installer)
|
||||
|
||||
Reference in New Issue
Block a user