React Native和AppHub:不存在捆绑URL

时间:2017-04-16 04:51:29

标签: ios xcode react-native

我在完成我的React Native项目之后坐在这里在AppHub上做快速入门,当它试图取消注释这些行时,我得到No bundle URL present错误。

AHBuild *build = [[AppHub buildManager] currentBuild];
  jsCodeLocation = [build.bundle URLForResource:@"main"
                                  withExtension:@"jsbundle"];

我该如何解决这个问题?

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [AppHub setApplicationID:@"25QLeX4o6N8Xm0naFxnx"];

  NSURL *jsCodeLocation;

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

  /**
   * OPTION 3 - AppHub
   *
   * Load cached code and images from AppHub.
   *
   */

  AHBuild *build = [[AppHub buildManager] currentBuild];
  jsCodeLocation = [build.bundle URLForResource:@"main"
                                  withExtension:@"jsbundle"];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"Hang"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  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;
}

1 个答案:

答案 0 :(得分:0)

在这方面,文档相当差,代码更具信息性。归档应用程序时,代码将起作用 - 它只是在debug模式下

它确实声明在部署时取消注释以下代码。

AHBuild *build = [[AppHub buildManager] currentBuild];
  jsCodeLocation = [build.bundle URLForResource:@"main"
                                  withExtension:@"jsbundle"];

要在模拟器上对此进行测试,请转至

将架构更改为release

产品> 架构> 修改架构> 将构建配置更改为release

这基本上就是存档所做的事情。

enter image description here