【发布时间】:2020-03-18 08:06:08
【问题描述】:
当我尝试从 XCode 中的 Release mode 构建我的 React Native 应用程序以在将其投入生产之前进行检查时,它会卡在旧代码中。无论我在我的 JS 文件中进行什么更改,它都不会这样做。在调试模式下它不会发生,就像它应该的那样工作正常。
例子:
我更改了我的任何 JS 文件中的标签,例如某些菜单的标题,当我使用 react-native run-ios 或如果在方案中选中“调试”时按下 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
【问题讨论】:
-
你能试试这个 ios re-bundler 命令吗:
react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios/assets -
嗨@Kuray-FreakyCoder-。它创建了一个新的 main.jsbundle,但是当我构建和运行时仍然没有改变任何东西。
-
你能和我分享一个可重现的例子吗?
-
我真的不知道如何分享一个可重现的示例。如果方案处于发布模式,我的应用程序会忽略我会做的任何更改。如果我运行 react-native run-ios 命令或将方案置于调试模式,它将正常工作。要上传到应用商店,我需要正确的发布模式。
-
我测试 rn ios 应用程序的方法是:构建存档并上传,然后使用 TestFlight 应用程序进行测试
标签: ios xcode react-native build