升级以响应本机0.59.10后无法加载捆绑软件(ios)

时间:2019-09-26 04:19:14

标签: ios react-native

将项目从0.55.4升级到0.59.10时遇到一些问题。它可以成功构建,但是之后我显示节点服务器错误。

这是升级前的我的AppDelegate.m。没关系。该应用程序运行正常。

#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

这是升级到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

显示此错误 enter image description here

这是我的IP地址

enter image description here

我想念什么吗?有人可以帮助我吗?谢谢!

1 个答案:

答案 0 :(得分:0)

通过以下步骤解决:

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