简体   繁体   English

在 React Native 的 iOS 项目中找不到“config.h”文件

[英]“config.h” file not found in iOS project of React native

In X-Code project of react native, getting error在 React Native 的 X-Code 项目中,出现错误

config.h file not found.找不到 config.h 文件。

Here is version detail :这是版本详细信息:

react-native-cli: 2.0.1
react-native: 0.51.0

How to solve it?如何解决?

  1. Close Xcode.关闭 Xcode。

  2. Open Terminal, go to your project's root folder and run:打开终端,转到项目的根文件夹并运行:

     cd node_modules/react-native/third-party/glog-0.3.4/
  3. Run the configure script:运行配置脚本:

     ./configure
  4. Open Xcode and try to run your app.打开 Xcode 并尝试运行您的应用程序。

I had the same issue, using this steps solves for me:我遇到了同样的问题,使用以下步骤为我解决了:

Running into the same issue here after upgrading from 0.44.从 0.44 升级后在这里遇到同样的问题。 None of the above solutions or clearing caches did the trick for me.上述解决方案或清除缓存都没有对我有用。 Here's what I did to get things working again:这是我为让事情重新开始所做的工作:

  1. In the Terminal, navigate to the react-native/third-party/glog folder inside node_modules (for me, this was cd node_modules/react-native/third-party/glog-0.3.4 )在终端中,导航到react-native/third-party/glogreact-native/third-party/glog文件夹(对我来说,这是cd node_modules/react-native/third-party/glog-0.3.4
  2. Once actively in this folder, run sh ../../scripts/ios-configure-glog.sh Glog is configured and the required config.h header file is created for Xcode to find一旦主动进入这个文件夹,运行sh ../../scripts/ios-configure-glog.sh配置glog并创建所需的config.h头文件供Xcode查找
  3. Run your iOS BUILD运行你的 iOS BUILD

Regards!问候!

When project files get messed up for me.当项目文件对我来说搞砸了。 I typically follow these steps.我通常遵循这些步骤。

rm -rf node_modules
npm install
react-native upgrade (Only changing affected files, so IOS for you)
react-native link
npm start --reset-cache
(In another terminal)
react-native run-ios

These steps worked for me:这些步骤对我有用:

rm -rf ~/.rncache
rm -rf node_modules/
npm install
npm start

You need to change to the legacy build system in Xcode 10 and install third party scripts manually.您需要在 Xcode 10 中更改为旧版构建系统并手动安装第三方脚本。

1: 1:

File -> Project/Workspace settings Build System: dropdown -> change to Legacy Build system文件 -> 项目/工作区设置构建系统:下拉列表 -> 更改为旧版构建系统

2: Follow this to manually install third party scripts for RN: 2:按照此为RN手动安装第三方脚本:

Clean RN cache清理 RN 缓存

$ rm -rf ~/.rncache $ rm -rf ~/.rncache

Re-install the deps重新安装deps

$ cd your_project_path $ rm -rf node_modules/ && npm install $ cd your_project_path $ rm -rf node_modules/ && npm install

Then install the third-party然后安装第三方

$ cd node_modules/react-native/scripts $ ./ios-install-third-party.sh $ cd node_modules/react-native/scripts $ ./ios-install-third-party.sh

Run the commands below if glog installation failed.如果 glog 安装失败,请运行以下命令。

$ cd ../third-party/glog-0.3.x $ ./configure $ cd ../第三方/glog-0.3.x $ ./configure

It works for me, I hope it helps for you.它对我有用,希望对你有帮助。

If above all answers don't work, Please check that there is no space in any directory name of the full path and not only the project directory name.如果以上所有答案都不起作用,请检查完整路径的任何目录名称中是否有space而不仅仅是项目目录名称。

While in terminal, it accepts throgh My Disk as My\\ Disk but xcode do not recognize that.在终端中,它接受通过My Disk作为My\\ Disk但 xcode 无法识别。

If its in My Disk directory, try after moving it to Desktop or any other directory which doesn't have space in their name.如果它在我的磁盘目录中,请尝试将其移动到桌面或名称中没有空格的任何其他目录。

configure: error: unsafe absolute working directory name Issue:配置:错误:不安全的绝对工作目录名称问题:

-Open Terminal, go to your project's root folder and run: - 打开终端,转到项目的根文件夹并运行:

  • cd node_modules/react-native/third-party/glog-0.3.5/ Run the configure script: cd node_modules/react-native/third-party/glog-0.3.5/ 运行配置脚本:

./configure ./配置

got error: configure: error: unsafe absolute working directory name得到错误:配置:错误:不安全的绝对工作目录名称

try to created app in desktop and from there run ./configure command.尝试在桌面上创建应用程序,然后从那里运行 ./configure 命令。

Please note with XCOXE 10, and Mojave MAC OS , I had same issue, ./configure was showing some permission issue, I had set permission "777" to project folder enclosing with inner folders请注意 XCOXE 10 和 Mojave MAC OS,我遇到了同样的问题,./configure 显示了一些权限问题,我已将权限“777”设置为包含内部文件夹的项目文件夹

This is the linking issue in xcode.这是 xcode 中的链接问题。 You just need to re-link the files.您只需要重新链接文件。 Please follow the below steps:请按照以下步骤操作:

  1. Open you peoject's root directory then open node-module -> react-native -> React .打开 peoject 的根目录,然后打开node-module -> react-native -> React
  2. Open React.xcodeproj file in xcode.在 xcode 中打开React.xcodeproj文件。
  3. You will see missing (showing red in color) files under the third-party folder您将在第三方文件夹下看到丢失的(显示为红色)文件
  4. Just run the React.xcodeproj project.只需运行 React.xcodeproj 项目。
  5. After completion close this project & open you project file.完成后关闭此项目并打开您的项目文件。
  6. Delete Drive data & Clean the project & run. 删除驱动器数据并清理项目并运行。

If after running the project you are getting linking issue then please make sure you have added all the (ios) products () come under the Libraries -> React.xcodeproj -> Products in your Build Phases -> Link Binary With Libraries .如果在运行项目后遇到链接问题,请确保已将所有 (ios) products () 添加到Libraries -> React.xcodeproj -> Products in your Build Phases -> Link Binary With Libraries

If everyone has tried solving the issue by this Open Terminal, go to your project's root folder and run: cd node_modules/react-native/third-party/glog-0.3.4/ Run the configure script: ./configure如果每个人都尝试通过此Open Terminal解决问题,请转到项目的根文件夹并运行:cd node_modules/react-native/third-party/glog-0.3.4/ 运行配置脚本:./configure

But still not got the solution then,但还是没有得到解决方案,

Go to your Xcode and check if there any library is missing.转到您的 Xcode 并检查是否缺少任何库。 Add that library and then perform this above step.添加该库,然后执行上述步骤。

What finally worked for me was the following:最终对我有用的是以下内容:

  1. cd node_modules/react-native
  2. ./scripts/ios-install-third-party.sh
  3. cd third-party/glog-[version]
  4. ./configure

The credit goes to this post: https://github.com/facebook/react-native/issues/20774#issuecomment-424745903 .归功于这篇文章: https : //github.com/facebook/react-native/issues/20774#issuecomment-424745903 According to it, the third-party directory's location is incorrect.据此, third-party目录的位置不正确。 It should be node_modules/react-native/third-party , but if you run the scripts as some answers here suggest, those dependencies get installed in react-native/scripts/third-party .它应该是node_modules/react-native/third-party ,但是如果您按照此处的某些答案建议运行脚本,则这些依赖项将安装在react-native/scripts/third-party

Although the already mentioned answers are correct but still few guys are struggling, as only configuring the glog doesn't sometimes resolve the error.尽管已经提到的答案是正确的,但仍然很少有人在挣扎,因为仅配置 glog 有时并不能解决错误。 Here I have written a detailed solution to the problem.这里我写了一个详细的解决问题的方法。

Solution: config.h file not found mutex.h During Archive . 解决方案:在存档期间找不到 config.h 文件 mutex.h

The steps are the following:步骤如下:

  1. Remove node_modules directory删除 node_modules 目录
  2. Clear Cache清除缓存
  3. Install packages again with Yarn使用 Yarn 再次安装软件包
  4. Install third party安装第三方
  5. Configure Glog配置 Glog
  6. Make & Make install glog Make & Make 安装 glog

For all these above steps the I have shared commands in the above mentioned article, so not going to write again.对于以上所有步骤,我已经在上面提到的文章中分享了命令,所以不打算再写了。 I hope it will solve problem for guys who are still struggling.我希望它可以为仍在挣扎的人解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到react-native xcode 10.1“ config.h”文件 - react-native xcode 10.1 “config.h” file not found 未找到 React Native Config.h - React Native Config.h not found 如何解决“找不到config.h文件”? 从设备上的本机反应运行应用程序时? - How to solve “config.h file not found”? when running app from the react native on the device? 致命错误:在 react-native@0.68 中找不到“config.h”文件 - Fatal error: 'config.h' file not found in react-native@0.68 'absl/base/config.h' 文件未找到 - 'absl/base/config.h' file not found 无法在IOS上运行简单的React本机项目致命错误'config.h'打印条目'CFBundleIndentifier'不存在 - Unable to run simple React native project on IOS fatal error 'config.h' print entry 'CFBundleIndentifier' does not exist 找不到config.h文件,并且:CFBundleIdentifier不存在。 错误 - config.h file not found and :CFBundleIdentifier does not exist. ERROR Mutex.h文件中的Mattermost app错误:找不到Config.h文件Xcode 10.1 - Mattermost app Error in mutex.h file: Config.h file not found Xcode 10.1 移动第三方文件夹后找不到“config.h”文件 - 'config.h' file not found after moving the third-party folder React Native IOS-找不到ImagePickerManager.h文件 - React Native IOS - ImagePickerManager.h file not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM