在完成我的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; }I'm sitting here doing the quickstart on AppHub after finishing my React Native project, and when it gets to the point of trying to uncomment out these lines, I get a No bundle URL present error.
AHBuild *build = [[AppHub buildManager] currentBuild]; jsCodeLocation = [build.bundle URLForResource:@"main" withExtension:@"jsbundle"];How can I fix this?
- (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; }最满意答案
文档在这方面相当差,代码更丰富。 当存档应用程序时,代码将起作用 - 它不会处于debug模式
它确实声明在部署时取消注释以下代码。
AHBuild *build = [[AppHub buildManager] currentBuild]; jsCodeLocation = [build.bundle URLForResource:@"main" withExtension:@"jsbundle"];要在模拟器上进行测试,请通过转到更改要release的模式
产品 > 架构 > 编辑架构 >将构建配置更改为release
这基本上是档案所做的。
Documentation is rather poor in this regards and code be more informative. When you archive the application the code will work - it just won't in debug mode
It does state that to uncomment the following code when deploying.
AHBuild *build = [[AppHub buildManager] currentBuild]; jsCodeLocation = [build.bundle URLForResource:@"main" withExtension:@"jsbundle"];To test this on the simulator change the schema to release by going to
Product > Schema > Edit Schema > Change build configuration to release
This is basically what an archive does.
更多推荐
发布评论