当我尝试构建我的 React Native 应用程序时XCode
in Release mode
在将其投入生产之前进行检查,它是否会陷入旧代码中。无论我对 JS 文件进行什么更改,它都不会执行此操作。在调试模式下,这种情况不会发生,只是正常工作。
Example:
我更改任何 JS 文件中的标签(例如某些菜单的标题),当我使用时它会起作用react-native run-ios
或者,如果在方案中选中“调试”,则按 XCode 的“播放”按钮。相反,如果我选中“发布”,它会对我的应用程序的旧版本收费,我什至不知道具体是哪个版本。
我尝试过投入生产,但仍然是旧版本。
所以,现在我无法上传新版本,因为无论我做什么更改,发布模式都会忽略它。
我尝试生成一个新的main.jsbundle
,我已经清理了构建Shift + CMD + K
我也重新安装了我的npm
没有解决办法。
你有什么主意吗?
EDIT:
文件“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 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 和 asset 文件夹并将它们放在 /ios/ProjectName 中
感谢大家的帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)