ios - React Native iOS Release 构建停留在旧代码上,但 Debug 构建工作正常
问题描述
当我尝试从 in 构建我的 React Native AppXCode
以在Release mode
将其启动到生产之前进行检查时,它会卡在旧代码中。无论我在我的 JS 文件中进行什么更改,它都不会这样做。在调试模式下它不会发生,就像它应该的那样工作正常。
例子:
react-native run-ios
我更改了我的任何 JS 文件中的标签,例如某些菜单的标题,当我使用或按下 XCode 的“播放”按钮时,如果在“调试”方案中被选中,它将起作用。相反,如果我选中“发布”,它会收取我什至不知道是哪个版本的应用程序的旧版本。
我已尝试投入生产,但仍然是旧版本。
所以,现在有一天我无法上传新版本,因为无论我做什么更改,发布模式都会忽略它。
我试图生成一个新的main.jsbundle
,我已经清理了构建,Shift + CMD + K
并且我也重新安装了我npm
的没有解决方案。
你有什么主意吗?
编辑:
文件“AppDelegate.m”与它有什么关系吗?
这是我的 AppDelegate:
#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"BottomNavigation"
initialProperties:nil];
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;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
@end
解决方案
正如我在这里发布的: https ://stackoverflow.com/a/59029751/8898886
最后我找到了解决方案。
问题是我生成的 main.jsbundle 放在错误的位置,同时有 2 个 main.jsbundle,旧的和损坏的和正确的。
我在 /ios/ProjectName 外面有一个正确的,而在那里有一个旧的。我只需要应用这个片段,它会生成一个新的和干净的main.jsbundle
:
react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios/assets
然后获取文件 main.jsbundle 和 assets 文件夹并将它们放在 /ios/ProjectName 中
谢谢大家的帮助。
推荐阅读
- javascript - 行中不存在 prop depto_modules.length,我该如何解决?
- groovy - 是否有任何简单有效的方法来编写我用来将日期和时间转换为 Groovy 中的时间戳的代码块
- jquery - 选择框选项 remove() 有效,但 hide() 无效
- python - 在多个变量中具有唯一的随机数
- python - 如何在 Python3 中加速“for循环”
- python - 在二维数组python上映射int
- java - 从键值(环境)传递到关系(实体)时,Xodus 会产生一个巨大的文件
- video - 使用 ffmpeg 从图像和 MP3 文件创建 iPhone 兼容视频
- c++ - g ++用户定义的动态链接库上的全局new和delete运算符
- rust - 如何返回引用和被引用的对象?