使用离线捆绑包在iOS设备上运行app 的官方React Native文档说
打开ios/YourApp/AppDelegate.m
取消注释该行,jsCodeLocation = [[NSBundle mainBundle] ...
使用最新版本react-native 0.30.0,此行不再出现在默认AppDelegate.m文件中.摘录自默认AppDelegate.m文件
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"TestAppDelete"
initialProperties:nil
launchOptions:launchOptions];
Run Code Online (Sandbox Code Playgroud)
如果我尝试使用jsCodeLocation以前版本中的那个,它将返回null
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
Run Code Online (Sandbox Code Playgroud)
我不知道为什么main.jsbundle返回的URL为null.它不是由包装商创造的.如果它也应该使用最新版本创建,我该如何确认?
如果您react-native 0.30.0使用离线捆绑包在iOS设备上运行应用,请分享相关说明.
nab*_*abn 25
编辑:整个捆绑ip检测应该在最新版本的react-native上自动进行.如果您在xcode上选择设备,请build and run运行一次应用程序.它应该在手机上保存一个脱机捆绑包,这样如果它找不到运行的打包服务器,它将使用脱机捆绑包.
来源:https://github.com/facebook/react-native/commit/8c29a52c54392ce52148e7d3aa9f835537453aa4
如果您release在构建应用程序时更改为方案,则会使用脱机捆绑包编译您的应用程序.
产品> Scheme> Edit Scheme>设置build configuration为Release.
不确定为什么他们没有更新该Appdelegate.m方法的文档.看起来这条线仍然存在于源头上.[编辑:有一个拉动请求 ]
小智 11
当我在ShadowsocksX中打开全局代理时,自动IP检测不会http://localhost:8081/index.ios.bundle在调试模式下返回.这就是为什么main.jsbundle的URL返回为null.
怎么解决?
选项1:
更换
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
Run Code Online (Sandbox Code Playgroud)
同
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
Run Code Online (Sandbox Code Playgroud)
此方法可以禁用自动IP检测.
选项2:
如果打开全局代理模式,请切换代理模式.
| 归档时间: |
|
| 查看次数: |
15666 次 |
| 最近记录: |