Created
March 27, 2018 11:43
-
-
Save yeatse/7259d37ab730659065fb734bda3aeae5 to your computer and use it in GitHub Desktop.
Work on RCTFont SIGABRT crash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (c) 2015-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
*/ | |
#import "AppDelegate.h" | |
#import <React/RCTBundleURLProvider.h> | |
#import <React/RCTRootView.h> | |
#import <React/RCTBridge+Private.h> | |
@interface AppDelegate () <RCTBridgeDelegate> | |
@property (nonatomic) RCTBridge *rctBridge; | |
@end | |
@implementation AppDelegate | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
self.rctBridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; | |
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:self.rctBridge moduleName:@"myapp" 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; | |
} | |
- (void)applicationWillTerminate:(UIApplication *)application | |
{ | |
RCTBridge *batchedBridge = self.rctBridge.batchedBridge; | |
[self.rctBridge invalidate]; | |
NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; | |
NSArray<NSRunLoopMode> *allModes = CFBridgingRelease(CFRunLoopCopyAllModes(runLoop.getCFRunLoop)); | |
while (batchedBridge.moduleClasses) { | |
for (NSRunLoopMode mode in allModes) { | |
[runLoop runMode:mode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; | |
} | |
} | |
} | |
#pragma mark - RCTBridgeDelegate | |
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge | |
{ | |
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; | |
} | |
@end |
@mujavidb If you create your app with command create-react-native-app
, you can modify your AppDelegate.m
as this gist. For more explanation please see this issue.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could you give a mini run-through on how this works? Or if you got it from another source, could you provide a link?
I've been getting this problem in prod more and more, so would really appreciate it. Thanks.