- 手机和电脑连在同一个 wifi 环境(局域网)下,获取电脑的 IP 地址
<img src="http://upload-images.jianshu.io/upload_images/1495175-446eb748771af49b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/450" width = "100" height = "80" alt="获取电脑 IP 地址" align=center />
- 将
localhost 修改为你电脑的 IP 地址
- 方法一:将
jsLocation 设置为自己电脑的 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];
- 方法二:将
RCTBundleURLProvider.m 文件中 - (NSString *)guessPackagerHost 方法中的 localhost 替换为你电脑的 IP 地址
NSString *host = ipGuess ?: @"10.169.3.167";
- 选择手机,直接 Run 即可
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。