简体   繁体   English

升级到反应原生 0.59.10 后无法加载包 (ios)

[英]Failed to load bundle (ios) after upgrading to react native 0.59.10

I'm getting some issues when I upgrade my project from 0.55.4 to 0.59.10.当我将项目从 0.55.4 升级到 0.59.10 时,我遇到了一些问题。 It can be built successfully but after that I shows node server error.它可以成功构建,但之后我显示节点服务器错误。

Here is my AppDelegate.m before upgrading.这是我升级前的 AppDelegate.m。 It's okay.没关系。 The app run as I expected.该应用程序按我的预期运行。

#import ...

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    //some codes here...

    NSURL *jsCodeLocation;

    #ifdef DEBUG
    NSString *url = @"http://localhost";
    url = @"http://192.168.2.125";

    NSString *urlBody = @":8081/index.bundle?platform=ios&dev=true";
    NSString *urlFull = [NSString stringWithFormat:@"%@%@",url, urlBody];

    jsCodeLocation = [NSURL URLWithString:urlFull];

    #else
        jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
    #endif

    RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"Cloud9"
                                                      initialProperties:nil
                                                      launchOptions:launchOptions];

    //some codes here...
}

//some codes here...

@end

And here is the AppDelegate.m after upgrading to 0.59.10这是升级到 0.59.10 后的 AppDelegate.m

#import ...

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    //some codes here...

    RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
    RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"Cloud9"
                                                      initialProperties:nil
                                                      launchOptions:launchOptions];

    //some codes here...
}

//some codes here...

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
    #if DEBUG
        NSString *url = @"http://localhost";
        url = @"http://192.168.2.125";
        NSString *urlBody = @":8081/index.bundle?platform=ios&dev=true";
        NSString *urlFull = [NSString stringWithFormat:@"%@%@",url, urlBody];

        return [NSURL URLWithString:urlFull];
    #else
        return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
    #endif
}

@end

It shows this error它显示了这个错误在此处输入图像描述

And this is my ip address这是我的 ip 地址

在此处输入图像描述

Am I missing something?我错过了什么吗? Anyone can help me?任何人都可以帮助我吗? Thanks!谢谢!

Solved by these steps:通过以下步骤解决:

  1. rm -rf ios/build/ rm -rf ios/构建/
  2. kill $(lsof -t -i:8081)杀死 $(lsof -t -i:8081)
  3. react-native run-ios react-native run-ios

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React Native Ios错误'无法加载包' - React Native Ios error 'failed to load bundle' React Native - 无法在 iOS 中加载包 - React Native - Failed to load bundle in iOS 升级 Xcode 12.5 后,无法在 iOS 上运行本机反应 - Failed to run react native on iOS after upgrading Xcode 12.5 升级到 React Native 0.60.5 iOS 版本后,出现“No bundle URL present”错误 - After upgrading to React Native 0.60.5 iOS release build gives "No bundle URL present" error React Native:无法在iOS上正确运行app“无法加载bundle(http:// localhost:8081 / index.bundle?” - React Native: Can't run app on iOS correctly “Failed to load bundle(http://localhost:8081/index.bundle?” 负载捆绑8081的解决方法失败后,react native无法找到package.json - react native can't find package.json after workaround for load bundle 8081 failed 无法为 react-native 加载带有 aws-sdk 的捆绑包 - Failed to load bundle with aws-sdk for react-native 反应原生升级后反应原生 iOS 构建失败 - React Native iOS build failed after react native upgrade mac os升级xcode后如何运行npm react-native run-ios? - How to run `npm react-native run-ios` after upgrading mac os and upgrading xcode? React Native:执行“yarn ios”后构建失败 - React Native : BUILD FAILED after doing "yarn ios"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM