鍍金池/ 問答/HTML5  iOS/ React Native 離線打包提示No bundle URL present

React Native 離線打包提示No bundle URL present.

React Native 離線打包后打開App提示以下錯(cuò)誤:

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文件,并添加到項(xiàng)目中,如下圖:

圖片描述

AppDelegate.m 配置代碼如下:

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

成功運(yùn)行后打開提示以上錯(cuò)誤,請(qǐng)問怎么解決?

回答
編輯回答
賤人曾

問題已找到,代碼jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"assets/index.ios" withExtension:@"jsbundle"];拼寫錯(cuò)誤。

2018年2月27日 01:15