mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Enable Flipper on RNTester (iOS)
Summary: By enabling Flipper on RNTester, we can ensure that Flipper continues to work with ReactNative. Note that Flipper is disabled when RNTester is built with `USE_FRAMEWORKS=1 pod install` Reviewed By: PeteTheHeat Differential Revision: D6976784 fbshipit-source-id: 4e16a47949d7ed6400e0b8ccd640be0754203c69
This commit is contained in:
committed by
Facebook Github Bot
parent
0cc4306d6c
commit
0a5c43fcc3
@@ -7,6 +7,40 @@ if ENV['USE_FRAMEWORKS'] == '1'
|
||||
use_frameworks!
|
||||
end
|
||||
|
||||
# Add Flipper Poods
|
||||
def flipper_pods()
|
||||
flipperkit_version = '0.23.4'
|
||||
pod 'FlipperKit', '~>' + flipperkit_version, :configuration => 'Debug'
|
||||
pod 'FlipperKit/FlipperKitLayoutPlugin', '~>' + flipperkit_version, :configuration => 'Debug'
|
||||
pod 'FlipperKit/SKIOSNetworkPlugin', '~>' + flipperkit_version, :configuration => 'Debug'
|
||||
pod 'FlipperKit/FlipperKitUserDefaultsPlugin', '~>' + flipperkit_version, :configuration => 'Debug'
|
||||
end
|
||||
|
||||
# Post Install processing for Flipper
|
||||
def flipper_post_install(installer)
|
||||
installer.pods_project.targets.each do |target|
|
||||
if target.name == 'YogaKit'
|
||||
target.build_configurations.each do |config|
|
||||
config.build_settings['SWIFT_VERSION'] = '4.1'
|
||||
end
|
||||
end
|
||||
end
|
||||
file_name = Dir.glob("*.xcodeproj")[0]
|
||||
app_project = Xcodeproj::Project.open(file_name)
|
||||
app_project.native_targets.each do |target|
|
||||
target.build_configurations.each do |config|
|
||||
cflags = config.build_settings['OTHER_CFLAGS'] || '$(inherited) '
|
||||
unless cflags.include? '-DFB_SONARKIT_ENABLED=1'
|
||||
puts 'Adding -DFB_SONARKIT_ENABLED=1 in OTHER_CFLAGS...'
|
||||
cflags << ' -DFB_SONARKIT_ENABLED=1'
|
||||
end
|
||||
config.build_settings['OTHER_CFLAGS'] = cflags
|
||||
end
|
||||
app_project.save
|
||||
end
|
||||
installer.pods_project.save
|
||||
end
|
||||
|
||||
def pods()
|
||||
project 'RNTesterPods.xcodeproj'
|
||||
|
||||
@@ -26,6 +60,9 @@ end
|
||||
|
||||
target 'RNTester' do
|
||||
pods()
|
||||
if ENV['USE_FRAMEWORKS'] != '1'
|
||||
flipper_pods()
|
||||
end
|
||||
end
|
||||
|
||||
target 'RNTesterUnitTests' do
|
||||
@@ -39,6 +76,9 @@ target 'RNTesterIntegrationTests' do
|
||||
end
|
||||
|
||||
post_install do |installer|
|
||||
if ENV['USE_FRAMEWORKS'] != '1'
|
||||
flipper_post_install(installer)
|
||||
end
|
||||
installer.pods_project.targets.each do |target|
|
||||
puts target.name
|
||||
end
|
||||
|
||||
@@ -29,6 +29,16 @@
|
||||
|
||||
#import <ReactCommon/RCTTurboModuleManager.h>
|
||||
|
||||
#if DEBUG
|
||||
#ifdef FB_SONARKIT_ENABLED
|
||||
#import <FlipperKit/FlipperClient.h>
|
||||
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
|
||||
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
|
||||
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
|
||||
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#import "RNTesterTurboModuleProvider.h"
|
||||
|
||||
@interface AppDelegate() <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate>{
|
||||
@@ -45,6 +55,7 @@
|
||||
|
||||
- (BOOL)application:(__unused UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
[AppDelegate initializeFlipper:application];
|
||||
RCTEnableTurboModule(YES);
|
||||
|
||||
_bridge = [[RCTBridge alloc] initWithDelegate:self
|
||||
@@ -181,6 +192,22 @@
|
||||
[RCTPushNotificationManager didReceiveLocalNotification:notification];
|
||||
}
|
||||
|
||||
|
||||
+ (void) initializeFlipper:(UIApplication *)application
|
||||
{
|
||||
#if DEBUG
|
||||
#ifdef FB_SONARKIT_ENABLED
|
||||
FlipperClient *client = [FlipperClient sharedClient];
|
||||
SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
|
||||
[client addPlugin: [[FlipperKitLayoutPlugin alloc] initWithRootNode: application withDescriptorMapper: layoutDescriptorMapper]];
|
||||
[client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
|
||||
[client start];
|
||||
[client addPlugin: [[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
|
||||
[client start];
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user