Files
flipper/react-native/ReactNativeFlipperExample/ios/ReactNativeFlipperExample/AppDelegate.m
Michel Weststrate 5471b844bc Apply react-native migration 0.62.2 -> 0.63.4
Summary:
In D25244631 (92bd68a371) we bumped the react-native dep of Flipper but we didn't apply the migration guide (sorry for missing that in the review), so the ReactNativeExample fell apart when trying to build for iOS. This diff applies the migration guide which nicely fixes that:

https://react-native-community.github.io/upgrade-helper/?from=0.62.2&to=0.63.4

Recreating the Podfile.lock and running `./gradlew clean` fixed all build problems after that.

Verified that `yarn ios` and `yarn android`, and building from XCode all work.

Found (probably unrelated / existing) issues:
* custom plugins only show up after initial app start after refreshing the plugin list by navigating to another diffs first, so this seems to be a UI staleness bug
* Network plugin doesn't seem to work ion iOS (either not showing traffic or not showing data at all)

Reviewed By: passy

Differential Revision: D25755490

fbshipit-source-id: baea8b152fb252deda04291ec197ab87c2fbe3eb
2021-01-04 12:17:56 -08:00

77 lines
2.7 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>
#ifdef FB_SONARKIT_ENABLED
#import <FlipperKit/FlipperClient.h>
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
static void InitializeFlipper(UIApplication* application) {
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
@implementation AppDelegate
- (BOOL)application:(UIApplication*)application
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
#ifdef FB_SONARKIT_ENABLED
InitializeFlipper(application);
#endif
RCTBridge* bridge = [[RCTBridge alloc] initWithDelegate:self
launchOptions:launchOptions];
RCTRootView* rootView =
[[RCTRootView alloc] initWithBridge:bridge
moduleName:@"ReactNativeFlipperExample"
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
}
@end