mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
898b1db6d0
Summary: The integration of Flipper on iOS was crashing the template, and `test_ios_e2e` were failing because of it. Flipper integration must be wrapped inside `FB_SONARKIT_ENABLED`. Flipper's issues with Yoga and YogaKit were solved in Flipper 0.28.0, so let's update our integration to it, and we'll need to use Swift. We will be able to ship this in 0.62 (cc grabbou, axe-fb, priteshrnandgaonkar), and it should fix `test_ios_e2e` (cc hramos) � . ## Changelog [iOS] [Fixed] - Fix Flipper integration on and update Flipper to 0.30.0 Pull Request resolved: https://github.com/facebook/react-native/pull/27426 Test Plan: - Initialized an app with my branch as source. - Added `[AppDelegate initializeFlipper:application];` to `didFinishLaunchingWithOptions`. - Launched Flipper. - Ran the app (debug).  - Ran the app (release). - Everything succeeds, no Flipper connection available in release. Reviewed By: hramos Differential Revision: D18841468 Pulled By: axe-fb fbshipit-source-id: 73bb4810d1fbb6a96102848f8700ebb7c23a615b
69 lines
2.4 KiB
Objective-C
69 lines
2.4 KiB
Objective-C
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#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
|
|
{
|
|
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
|