React Native和AppHub:不存在任何包URL(React Native and AppHub: No bundle URL present)

编程入门 行业动态 更新时间:2024-10-28 22:25:34
React Native和AppHub:不存在任何包URL(React Native and AppHub: No bundle URL present)

在完成我的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.

enter image description here

更多推荐

本文发布于:2023-08-06 09:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1448311.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不存在   AppHub   Native   React   bundle

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!