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


当前回答

如果您正在运行IOS模拟器,请确保需要运行此命令

react-native运行android 或 npm运行android

一旦你运行以上命令metro bundler将启动,然后运行react- negative run-ios它将工作。

其他回答

确保你的项目中有.jsbundle

Add

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

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

使用命令

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

我发现绕过这个最简单/最快的方法是在模拟器中退出应用程序(2 x Cmd + Shift + H)并重新启动。

当您不允许通过localhost进行不安全连接时,或者您试图通过http接受不安全连接时,就会发生此问题。

要解决这个问题,在info.plist上添加这个:

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

检查你的网络代理,最好关闭它。

或者你应该找其他方法来维护打包服务器