为什么React Native 0.30没有从iPhone设备上的开发服务器获得更改?

nom*_*mad 6 react-native

自从我升级到React Native 0.30后,我的物理iPhone上的构建从预先捆绑的文件而不是开发服务器加载.查看更改的唯一方法是再次构建和运行应用程序.以前,我可以通过刷新立即在iPhone上看到更改.

如果我使用模拟器,那么从开发服务器更改负载就好了.

这是我的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
Run Code Online (Sandbox Code Playgroud)

NiF*_*iFi 5

您已设置jsCodeLocation使用捆绑包。将该行更改为

jsCodeLocation = [NSURL URLWithString:@"http://DEV_SERVER_URI:8081/index.ios.bundle?platform=ios&dev=true"];
Run Code Online (Sandbox Code Playgroud)

例如

jsCodeLocation = [NSURL URLWithString:@"http://192.168.0.7:8081/index.ios.bundle?platform=ios&dev=true"];
Run Code Online (Sandbox Code Playgroud)

您可以通过ifconfig在终端中运行来获取机器的公共 IP 。IP 地址列在 下en0:,成功inet


ste*_*nis -1

在 0.30 中,您不需要编写 jsCodeLocation runreact-native upgrade来迁移和进行更改