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


当前回答

对于Ios系统,请遵循以下步骤,

Rm -rf ./node_modules . Rm npm安装 react-native链接 cd ios 圆荚体安装 cd . . react-native开始 第一次在XCode中构建应用,然后你也可以使用VScode

其他回答

这是react-native v0.42.1的一个问题。尝试关闭所有终端和XCode实例并运行:

launchctl unload ~/Library/LaunchAgents/com.github.facebook.watchman.plist
watchman version
react-native run-ios

以下步骤:

用xcode打开ios文件项目 在项目包中删除main。jsbundle文件 通过main添加新的空文件。jsbundle名字 运行comment: react-native bundle——entry-file index.js——platform ios——dev false——bundle-output ios/main。Jsbundle——assets-dest ios 现在是react-native run-ios

youtube链接:https://www.youtube.com/watch?v=eCs2GsWNkoo

解决错误No bundle URL present by:

在你的项目根目录中运行以下命令删除iOS构建目录,并在重新构建之前杀死其他React Native会话(假设它们运行在默认端口8081上):

Rm -rf ios/build/;Kill $(lsof -t:8081);react-native run-ios

更新你的React Native工作流,通过将上述命令组合成一个别名,并将其附加到你的Bash配置文件.bashrc,以避免这些错误发生:

Echo "alias rni=\"kill \$(lsof -t -i:8081);Rm -rf ios/build/;React-native run-ios\"" >> ~/.bashrc;源~ / . bashrc

现在你可以用一个简单的别名快捷方式运行React Native iOS构建(不用担心出现一些常见的红色死亡错误屏幕):

rni

确保launchPackage.command在终端中运行,然后重试运行。它将构建捆绑包。它有点像webpack-dev-server。

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

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

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