gpt4 book ai didi

react-native - 使用脱机捆绑在iOS设备上运行react-native应用

转载 作者:行者123 更新时间:2023-12-03 14:32:52 25 4
gpt4 key购买 nike

使用脱机捆绑包在iOS设备上运行应用程序的官方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];

如果我尝试使用以前版本中的 jsCodeLocation,它将返回为null
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

我不确定为什么 main.jsbundle的URL返回为 null。打包程序不再创建它了吗?如果还应该使用最新版本创建它,该如何确认?
如果您已使用脱机捆绑包在iOS设备上运行 react-native 0.30.0应用,请共享说明。

最佳答案

编辑:整个bundle ip检测应该在最新版本的react-native上自动进行。如果您在xcode上选择设备,请执行build and run并运行一次该应用程序。它应该将脱机捆绑包保存在电话中,这样,如果找不到正在运行的打包器服务器,它将使用脱机捆绑包。

来源:https://github.com/facebook/react-native/commit/8c29a52c54392ce52148e7d3aa9f835537453aa4



如果在构建应用程序时更改为release方案,则将使用脱机捆绑包编译应用程序。

产品>方案>编辑方案>将build configuration设置为Release

不知道为什么他们不更新Appdelegate.m方法的文档。看起来该行仍然在源上。 [编辑:为此有一个pull request]

关于react-native - 使用脱机捆绑在iOS设备上运行react-native应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38780325/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com