Files
flipper/react-native/ReactNativeFlipperExample/ios/ReactNativeFlipperExample/AppDelegate.m
Lorenzo Blasa 2d4ca7003e Fixes RN iOS (#4053)
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/4053

Update usage of RN `RCTBundleURLProvider` `jsBundleURLForBundleRoot` API.

The previous signature was removed in the current used RN version.

Reference:
https://github.com/facebook/react-native/blob/main/React/Base/RCTBundleURLProvider.h

Reviewed By: aigoncharov

Differential Revision: D39256797

fbshipit-source-id: 2074698597f691f46f6ffd2f6b569e7742d5fffc
2022-09-05 04:25:50 -07:00

76 lines
2.7 KiB
Objective-C

/*
* 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.
*/
#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"];
#else
return [[NSBundle mainBundle] URLForResource:@"main"
withExtension:@"jsbundle"];
#endif
}
@end