【问题标题】:Can't build and run react-native project on Mac无法在 Mac 上构建和运行 react-native 项目
【发布时间】:2017-08-28 15:53:25
【问题描述】:

参考this 问题,我也有同样的问题。我在 VMware 上有 MacOs El Captain。

  • 节点 v. 7.8.0
  • npm v.4.6.1
  • react-native-cli 2.0.1
  • react-native 0.46.4
  • Xcode v. 8.2.1

我有两个问题: - 当尝试init 一个新的 react-native 项目时,获取的包会挂起从 repo 获取 react-native 0.46.4 包。其他包下载成功。所以我从 Windows 执行了npm install,然后在 Mac 上复制了node_modules 文件夹。 - 尝试在 iOS 模拟器上运行项目时,我收到以下错误:

** 构建失败 **

...
In file included from /Users/michelebombardi/Desktop/ReactNativeProjects/caliup/node_modules/react-native/React/../third-party/folly-2016.09.26.00/folly/Bits.h:70:
/Users/michelebombardi/Desktop/ReactNativeProjects/caliup/node_modules/react-native/React/../third-party/folly-2016.09.26.00/folly/detail/BitIteratorDetail.h:21:10: fatal error: 'boost/iterator/iterator_adaptor.hpp' file not found
#include <boost/iterator/iterator_adaptor.hpp>

The following build commands failed:

CompileC /Users/michelebombardi/Desktop/ReactNativeProjects/caliup/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/third-party.build/Objects-normal/x86_64/Conv.o /Users/michelebombardi/Desktop/ReactNativeProjects/caliup/node_modules/react-native/third-party/folly-2016.09.26.00/folly/Conv.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

Installing build/Build/Products/Debug-iphonesimulator/CaliUp.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist

Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/CaliUp.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist`

我真的需要在本周末之前在应用商店上发布我的应用。 我已经尝试了所有建议的解决方案,但没有任何效果。

谁能帮帮我?

【问题讨论】:

    标签: ios node.js macos react-native


    【解决方案1】:

    首先试试这个: watchman watch-del-all && rm -rf node_modules

    如果您使用 Homebrew 安装节点,请卸载它并从此处安装节点。(https://nodejs.org/en/)

    现在如果你使用 yarn 安装节点模块: 试试 npm 安装

    【讨论】:

      【解决方案2】:

      此错误是由构建步骤中的第三方库下载失败引起的。在您的主文件夹中应该有一个 ~/.rncache 目录,其中包含许多压缩的 C++ 库。当这些文件中的一个或多个无法从 github amazon s3 服务器完全下载时,就会发生错误。 (可能在中国)

      问题仍然存在,因为 react-native xcode 构建中的脚本不知道如何恢复损坏的下载。所以你可以通过删除你的 ~/.rncache 文件夹来解决这个问题,因为这些文件夹被提取到你的模块中,你还应该 rm -rf node_modules 并重新安装。

      更多信息可以在herehere找到

      【讨论】:

        【解决方案3】:

        也许这会起作用。请尝试以下步骤:

        1. 从 ios 文件夹中备份您的图标、图像等。

        2. 检查是否为 {project-root}\app.json 文件中的键“name”设置了应用名称。

        3. 删除 ios/ 和 android/ 目录

        4. 运行 react-native 弹出

        5. 替换您之前复制的图标、图像等

        6. 运行 react-native 链接

        7. 使用快捷键 command+r 从 Xcode 启动您的应用

        【讨论】:

        • 在我的 Mac 上使用 react-native 弹出重新生成 ios 和 android 文件夹解决了这个问题。非常感谢!
        • @Androidian 是的,重新生成 ios 和 android 文件夹是有帮助的,因为 react-native 的每个版本都有一些内部项目设置相关的更改。这就是为什么命令 watch-del-all 在这种情况下没有用的原因。
        猜你喜欢
        • 2021-12-20
        • 1970-01-01
        • 1970-01-01
        • 2020-05-16
        • 1970-01-01
        • 2019-03-27
        • 2022-09-30
        • 2019-11-25
        • 2018-12-14
        相关资源
        最近更新 更多