React-native-navigation: [iOS][v2] Support react-native 0.59.x

Created on 12 Mar 2019  ·  9Comments  ·  Source: wix/react-native-navigation

Issue Description

How to apply the changes made to AppDelegate.m in react-native 0.59.0?
diff ios/RnDiffApp/AppDelegate.m

Environment

  • React Native Navigation version: 2.13.1
  • React Native version: 0.59.0
  • Platform(s) (iOS, Android, or both?): IOS
  • Device info (Simulator/Device? OS version? Debug/Release?): Device

Most helpful comment

This worked for me:

#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

#import <ReactNativeNavigation/ReactNativeNavigation.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];

  [ReactNativeNavigation bootstrap:[self sourceURLForBridge: bridge] launchOptions:launchOptions];

  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

All 9 comments

Does something need to be done for 59 and iOS?

does not work on a new project. in .59
App hangs on launchscreen with old AppDelegate.m
AppDelegate.m has changed a lot:

/**
 * 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>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"Test"
                                            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

I have the same problem.
I don't know how to apply the changes made to AppDelegate.m in react-native 0.59.0.

Here is a link to the changes that were made: https://github.com/react-native-community/rn-diff-purge/compare/version/0.58.6...version/0.59.0

Does anyone has a project with react-native-navigation that already uses react-native 0.59.0?

I got to run it without any changes to the AppDelegate.m (not sure this is right approach).

Go here to solve any issues with upgrading to RN 0.59.0.
Click here to find out any differences between your version vs the most current. That's how I got my app up running with ease. Make sure to include any RNN navigation installation on the edits as well. https://github.com/react-native-community/rn-diff-purge. Anything with versions is ok to replace, just the main install code logic you need to be wary of.

@frederickalcantara What did you change in AppDelegate.m when you upgraded to the 0.59.0.

This worked for me:

#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

#import <ReactNativeNavigation/ReactNativeNavigation.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];

  [ReactNativeNavigation bootstrap:[self sourceURLForBridge: bridge] launchOptions:launchOptions];

  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

Hello,

I have the same problem.

Anything new ? How to use react native navigation with RN 0.59 ?

Thanks

Documentation should really be updated to reflect the changes since React Native 0.60.0.

Was this page helpful?
0 / 5 - 0 ratings