【问题标题】:React Native Config.h not found未找到 React Native Config.h
【发布时间】:2018-11-22 23:54:14
【问题描述】:

我是 React 原生开发者的初学者。

新建项目后打开。

xcode is display error config.h file not found in mutex.h 文件。我也在谷歌搜索并尝试可能的解决方案,但仍然显示相同的错误。

我已经完成了以下命令

1

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2

brew install watchman

3

npm install -g react-native-cli

4

react-native init projectName

5

cd projectName
react-native start

6

react-native run-ios

CMD 错误
./Desktop/Demo React Native/projectName/node_modules/react-native/React/../third-party/glog-0.3.4/src/base/mutex.h:105:10:致命错误:'config.h ' 找不到文件

include "config.h" // 确定 pthreads 支持

生成 1 个错误。

软件版本列表
自制 1.6.8
react-native-cli: 2.0.1
反应原生:0.55
守望者 4.9.0
npm 6.1.0

我也在尝试这个解决方案,但仍然出错

在终端中,导航到 third-party/glogconfig glog 文件

cd node_modules/react-native/third-party/glog-0.3.4
./../scripts/ios-configure-glog.sh

【问题讨论】:

    标签: javascript ios objective-c xcode react-native


    【解决方案1】:

    在项目目录中运行以下命令。帮助我解决了我的 config.h 未找到问题

    1. cd node_modules/react-native/third-party/glog-0.3.4/
    2. ./配置
    3. 制作
    4. 进行安装
    5. cd ../../../..
    6. react-native run-ios

    【讨论】:

    • 在 make 命令后显示 make: *** 没有规则可以使目标“安装”。停止。
    • 问题已解决 react-native init with lower version
    【解决方案2】:

    我按照以下步骤修复了它:

    1. 关闭Xcode
    2. cd <Project-Folder>/node_modules/react-native/third-party/glog-0.3.4
    3. 运行./configure
    4. 运行make
    5. 运行make install
    6. 打开 Xcode 并尝试构建项目。

    希望这能解决问题

    【讨论】:

    • 我要删除“node_modules”,然后运行“yarn install”命令,然后在你的 ans 2 和 3 步之后,使用 react-native 0.56 版本正确运行它
    • @BhaumikSurani 感谢您的见解...在某些情况下需要第 4 至第 5 步 ....没有时间真正了解为什么在某些情况下需要它..但上述步骤很友好解决方案使其工作
    • 我是 iOS 新手,make 是什么?
    • make 是一个构建工具,通常用于 C/C++ 项目。 gnu.org/software/make 它的作用是由目录中的Makefile 配置的。步骤3-5是构建和安装github.com/google/glog的步骤
    • 在这里工作。谢谢。
    【解决方案3】:

    我的问题来自于使用 react-native@0.53.0,我认为新 Xcode 版本有问题。

    1 - 更改 package.json 中的 react-native 版本

    "react-native": "0.53.0",
    

    "react-native": "0.56.0",
    

    2 - 删除 node_modules 文件夹

    $ rm -rf node_modules/
    

    3 - 重新安装模块:

    $ yarn install
    

    【讨论】:

      【解决方案4】:

      解决方案:

      yarn upgrade log
      

      升级到 v1.6.0 成功。 iOS 构建成功。

      注意:重建 glog 对我不起作用。构建失败。

      【讨论】:

        【解决方案5】:

        我会为这个问题添加另一个答案,因为这周让我发疯......

        $ cd ./node_modules/react-native && scripts/ios-install-third-party.sh && cd third-party && cd $(ls | grep 'glog' | awk '{print $1}') && ./configure
        

        手动配置 glog 所需的步骤(如 samridhgupta 他接受的答案或我在上面写的命令)对我有用,但只是在我第一次构建项目时。在每次构建时,我都必须执行相同的流程,因此我需要一个更稳定的解决方案。

        我似乎 Xcode 在每次构建时都在执行 ios-install-third-party.sh,这意味着它也会在每次构建时执行 ios-configure-glog.sh时间。所以我的解决方案是只构建一次,然后在 ios-install-third-party 脚本中注释掉 glog install 步骤。

        如果有人遇到同样的问题,则需要删除或注释掉下面的行(ios-install-third-party 可以在 /node_modules/react-native/scripts 中找到)。

        fetch_and_unpack glog-0.3.5.tar.gz https://github.com/google/glog/archive/v0.3.5.tar.gz 61067502c5f9769d111ea1ee3f74e6ddf0a5f9cc "\"$SCRIPTDIR/ios-configure-glog.sh\""
        

        【讨论】:

          【解决方案6】:

          什么对我有用:

          yarn cache clean
          rm -rf node_modules
          yarn install
          

          【讨论】:

            【解决方案7】:

            如果这些解决方案中的任何一个不起作用,请检查您的项目路径。项目路径 - 目录名称中不应包含任何空格,或者您可以在 Desktop 或 Documents 目录中创建项目。

            【讨论】:

              【解决方案8】:

              将此fix 脚本添加到package.json

              "scripts": {
                  "fix": "cd node_modules/react-native/third-party/glog-0.3.4 && ./configure && make && make install"
                },
              

              然后运行yarn fixnpm run fix 然后尝试构建项目

              【讨论】:

                猜你喜欢
                • 1970-01-01
                • 1970-01-01
                • 2019-10-17
                • 1970-01-01
                • 2022-01-24
                • 2019-04-07
                • 2017-11-03
                • 2020-05-27
                相关资源
                最近更新 更多