当我运行一个react-native项目时,我得到一个错误,没有bundle URL,但我不知道我做了什么错误,我很困惑。
当前回答
对我来说,问题是它不能创建JS包。当从Xcode构建时,它没有声明错误,所以你无法知道这一点。要查找错误,请运行以下命令。
React-native bundle——platform ios——dev false——entry-file index.ios.js——bundle-output ./ios/release/mainJsbundle——assets-dest ./ios/release/main.jsbundle
对我来说,错误是缺少PureRenderMixin组件。解决方案可以在这里找到:https://github.com/facebook/react-native/issues/13078。基本上你必须手动安装react@16.0.0-alpha.3。这可以通过运行这个命令来完成。
NPM I——保存react@16.0.0-alpha.3
现在每个人都遇到了这个问题,因为新版本的react alpha正在发布(特别是alpha.5),它们破坏了react原生构建。
其他回答
当我们有nvm管理的多个版本的节点,而默认版本不是react-native运行的预期版本时,可能会发生此问题。(确保它是Node 8.3或更新版本)
react-native run-ios
打开一个新终端并运行在$PATH中找到的node版本。
如果它发现一个不被react native支持的旧版本的node,它可能会给出这个错误。
确保在打开新终端时,$PATH变量已经指向预期的节点版本(确保它是node 8.3或更新版本)。
这为我解决了问题。祝你好运。
使用命令
react-native bundle --platform ios --dev false --entry-file index.js --bundle-output ./ios/release/main.jsbundle --assets-dest ./ios/release/main.jsbundle
当您不允许通过localhost进行不安全连接时,或者您试图通过http接受不安全连接时,就会发生此问题。
要解决这个问题,在info.plist上添加这个:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>
请确保.plist文件中的ATS设置是正确的。
你可以在/ios/{{project_name}}/Info.plist找到这个文件
Localhost必须定义为异常请求目标,如下所示:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
*(不要忘记在发布版本中删除此选项..)
对于我的用例,我必须删除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
推荐文章
- 如何在iOS中使用Swift编程segue
- Swift -整数转换为小时/分钟/秒
- Swift:声明一个空字典
- React钩子:从回调中访问最新状态
- 在成功提交我的应用程序后,“太多符号文件”
- 首先添加一个UIView,甚至是导航栏
- 我如何改变UIButton标题颜色?
- 在Swift中如何调用GCD主线程上的参数方法?
- NSLayoutConstraints是可动画的吗?
- iOS -构建失败,CocoaPods无法找到头文件
- React-Native:应用程序未注册错误
- 禁用react native按钮
- CFNetwork SSLHandshake iOS 9失败
- 请求失败:不可接受的内容类型:文本/html使用AFNetworking 2.0
- 缺少推荐的图标文件-该包不包含iPhone / iPod Touch的应用程序图标,像素为“120x120”,png格式