mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Issue: https://github.com/facebook/react-native/issues/27565 initalizeFlipper should be set in template app by default. ## Changelog [iOS] [Changed] - Added Flipper to template app [Android] [Changed] - Added Flipper to template app Pull Request resolved: https://github.com/facebook/react-native/pull/27569 Test Plan: Connect Flipper to the iOS application Connect Flipper to the Android application Reviewed By: passy Differential Revision: D19344704 Pulled By: rickhanlonii fbshipit-source-id: ca126fd2caab13751ddc2ce6d195bd0c644c704e
63 lines
2.2 KiB
Objective-C
63 lines
2.2 KiB
Objective-C
#import "AppDelegate.h"
|
|
|
|
#import <React/RCTBridge.h>
|
|
#import <React/RCTBundleURLProvider.h>
|
|
#import <React/RCTRootView.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>
|
|
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>
|
|
#endif
|
|
#endif
|
|
|
|
@implementation AppDelegate
|
|
|
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
|
{
|
|
[AppDelegate initializeFlipper:application];
|
|
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
|
|
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
|
|
moduleName:@"HelloWorld"
|
|
initialProperties:nil];
|
|
|
|
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
|
|
|
|
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
|
UIViewController *rootViewController = [UIViewController new];
|
|
rootViewController.view = rootView;
|
|
self.window.rootViewController = rootViewController;
|
|
[self.window makeKeyAndVisible];
|
|
return YES;
|
|
}
|
|
|
|
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
|
|
{
|
|
#if DEBUG
|
|
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
|
|
#else
|
|
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
|
|
#endif
|
|
}
|
|
|
|
+ (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 addPlugin: [FlipperKitReactPlugin new]];
|
|
[client addPlugin: [[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
|
|
[client start];
|
|
#endif
|
|
#endif
|
|
}
|
|
|
|
@end
|