为什么 React Native 0.30 没有从 iPhone 设备上的开发服务器获取更改? [英] Why does React Native 0.30 not get changes from development server on iPhone device?
问题描述
自从我升级到 React Native 0.30 后,我的物理 iPhone 上的构建就从预捆绑的文件而不是开发服务器加载.查看更改的唯一方法是再次构建和运行应用程序.以前,我可以通过刷新立即在 iPhone 上看到更改.
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.
这是我的 AppDelegate.m:
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
推荐答案
您已将 jsCodeLocation
设置为使用该包.将该行更改为
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"];
例如
jsCodeLocation = [NSURL URLWithString:@"http://192.168.0.7:8081/index.ios.bundle?platform=ios&dev=true"];
您可以通过在终端中运行 ifconfig
来获取您机器的公共 IP.IP 地址列在 en0:
下,在 inet
之后.
You can get your machine's public IP by running ifconfig
in a terminal. The IP address is listed under en0:
, succeeding inet
.
这篇关于为什么 React Native 0.30 没有从 iPhone 设备上的开发服务器获取更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!