加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

react-native – 为什么React Native 0.30没有从iPhone设备上的

发布时间:2020-12-15 05:06:57 所属栏目:百科 来源:网络整理
导读:自从我升级到React Native 0.30后,我的物理iPhone上的构建从预先捆绑的文件而不是开发服务器加载.查看更改的唯一方法是再次构建和运行应用程序.以前,我可以通过刷新立即在iPhone上看到更改. 如果我使用模拟器,那么从开发服务器更改负载就好了. 这是我的AppDe
自从我升级到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
您已将jsCodeLocation设置为使用该捆绑包.将该行更改为
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下.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读