React Native开发经验集iOS Developer

《React Native之从 0 到 1 》—— 真机调试篇

2017-01-05  本文已影响71人  OutMan_Coder
  1. 手机和电脑连在同一个 wifi 环境(局域网)下,获取电脑的 IP 地址
    <img src="https://img.haomeiwen.com/i1495175/446eb748771af49b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/450" width = "100" height = "80" alt="获取电脑 IP 地址" align=center />
  2. localhost 修改为你电脑的 IP 地址
NSURL *jsCodeLocation;
    [RCTBundleURLProvider sharedSettings].jsLocation = @"10.169.3.167";
    jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
    RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                    moduleName:@"AObjectiveCAndRractNative"
                                                 initialProperties:nil
                                                     launchOptions:nil];
    rootView.frame = _vReactNative.bounds;
    [_vReactNative addSubview:rootView];
NSString *host = ipGuess ?: @"10.169.3.167";
  1. 选择手机,直接 Run 即可
上一篇 下一篇

猜你喜欢

热点阅读