Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does React Native 0.30 not get changes from development server on iPhone device?

Tags:

react-native

Ever since I upgraded to React Native 0.30, the builds on my physical iPhone load from a pre-bundled file rather than the development server. The only way to see changes is to build and run the app again. Previously, I could see changes instantly on my iPhone by doing a refresh.

If I use a simulator, changes load from the development server just fine.

Here is my AppDelegate.m:

#import "AppDelegate.h"

#import "RCTBundleURLProvider.h"
#import "RCTRootView.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"upool"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  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;
}

@end
like image 635
nomad Avatar asked Aug 11 '16 18:08

nomad


1 Answers

You have set jsCodeLocation to use the bundle. Change that line to

jsCodeLocation = [NSURL URLWithString:@"http://DEV_SERVER_URI:8081/index.ios.bundle?platform=ios&dev=true"];

e.g.

jsCodeLocation = [NSURL URLWithString:@"http://192.168.0.7:8081/index.ios.bundle?platform=ios&dev=true"];

You can get your machine's public IP by running ifconfig in a terminal. The IP address is listed under en0:, succeeding inet.

like image 62
NiFi Avatar answered Oct 16 '22 17:10

NiFi