React Native 离线打包提示No bundle URL present.

React Native 离线打包后打开App提示以下错误:

2018-04-16 14:43:50.966 [fatal][tid:main] No bundle URL present.

Make sure you're running a packager server or have included a .jsbundle file in your application bundle.
2018-04-16 14:43:50.968629+0800 myapp[20467:9210948] No bundle URL present.

Make sure you're running a packager server or have included a .jsbundle file in your application bundle.
2018-04-16 14:43:50.968868+0800 myapp[20467:9210948] *** Terminating app due to uncaught exception 'RCTFatalException: No bundle URL present.

Make sure you're running a packager server or have included a .jsbundle file in your application bundle.', reason: 'No bundle URL present.

Make sure you're running a packager server or have ...'
*** First throw call stack:
(0x184e1ad8c 0x183fd45ec 0x104c3bd84 0x104c26d28 0x104fd5260 0x104fd5220 0x104fd9db0 0x184dc3070 0x184dc0bc8 0x184ce0da8 0x186cc3020 0x18ecc178c 0x104c126f0 0x184771fc0)
libc++abi.dylib: terminating with uncaught exception of type NSException

我已用命令react-native bundle --dev false --entry-file index.ios.js --bundle-output bundle/index.ios.jsbundle --platform ios 生成js文件,并添加到项目中,如下图:

图片描述

AppDelegate.m 配置代码如下:

jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"assets/index.ios" withExtension:@"jsbundle"];

成功运行后打开提示以上错误,请问怎么解决?

阅读 6.9k
1 个回答

问题已找到,代码jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"assets/index.ios" withExtension:@"jsbundle"];拼写错误。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题