当我运行一个react-native项目时,我得到一个错误,没有bundle URL,但我不知道我做了什么错误,我很困惑。


当前回答

对于我的用例,我必须删除node_modules目录并运行npm install。

$ rm -rf node_modules   (make sure you're in the ios project directory)
$ npm install

如果你得到错误“dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.58。Dylib”,执行以下操作:

$ brew uninstall --force node --ignore-dependencies node
$ brew uninstall icu4c --ignore-dependencies icu4c
$ brew install icu4c
$ brew unlink icu4c && brew link icu4c --force
$ brew install node

$ npm install

其他回答

我也有同样的错误,只能通过Xcode运行应用程序。React-native run-ios不起作用。要解决这个问题,你需要删除YOUR_PROJECT/ios/build/的build文件夹。在此之后,您应该能够再次通过react-native run-ios运行您的应用程序。希望这能有所帮助。

确保你的项目中有.jsbundle

Add

react-native bundle --dev false --entry-file index.js --bundle-output ios/main.jsbundle --platform ios

在react原生代码中 尝试重新打开项目

我也有同样的问题。但我的问题是我的Mac和iPhone不在同一个wifi网络中。

因此,确保它们都在同一个网络中,并再次重建。如果不是这样,试试其他成员在这里提到的解决方案。

在我的案例中,通过重新启动adb服务器解决了这个问题:adb kill-server && adb start-server

试着加上这句话:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSAllowsArbitraryLoadsInWebContent</key>
    <true/>
    <key>NSAllowsLocalNetworking</key>
    <true/>
</dict>