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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48019066/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 10:29:36  来源:igfitidea点击:

"config.h" file not found in iOS project of React native

iosxcodereact-native

提问by Jagdeep Singh

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?

如何解决?

回答by John Marshall

  1. Close 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.

  1. 关闭 Xcode。

  2. 打开终端,转到项目的根文件夹并运行:

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

    ./configure
    
  4. 打开 Xcode 并尝试运行您的应用程序。

回答by Deivison Sporteman

I had the same issue, using this steps solves for me:

我遇到了同样的问题,使用以下步骤为我解决了:

Running into the same issue here after upgrading from 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:

从 0.44 升级后在这里遇到同样的问题。上述解决方案或清除缓存都没有对我有用。这是我为让事情重新开始所做的工作:

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

Regards!

问候!

回答by Gavin Thomas

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

回答by yogevbd

These steps worked for me:

这些步骤对我有用:

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

回答by Minhaj Javed

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.

它对我有用,我希望它对你有帮助。

回答by imrohan

If above all answers don't work, Please check that there is no spacein any directory name of the full pathand not onlythe project directory name.

如果所有的答案以上不工作,请检查有没有space完整路径的任何目录名,并不仅是项目目录的名称。

While in terminal, it accepts throgh My Diskas My\ Diskbut xcode do not recognize that.

在终端中,它接受 throgh My DiskMy\ 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.

如果它在我的磁盘目录中,请尝试将其移动到桌面或名称中没有空格的任何其他目录。

回答by Naresh

This is the linking issue in xcode. You just need to re-link the files. Please follow the below steps:

这是 xcode 中的链接问题。您只需要重新链接文件。请按照以下步骤操作:

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

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 -> Productsin your Build Phases -> Link Binary With Libraries.

如果在运行项目后遇到链接问题,请确保已将所有 (ios) products () 添加到Libraries -> React.xcodeproj -> Productsin your Build Phases -> Link Binary With Libraries

回答by Sandeep Rajbhar

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. Add that library and then perform this above step.

转到您的 Xcode 并检查是否缺少任何库。添加该库,然后执行上述步骤。

回答by Victor Bogdan

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-0.3.4
  4. ./configure
  1. cd node_modules/react-native
  2. ./scripts/ios-install-third-party.sh
  3. cd third-party/glog-0.3.4
  4. ./configure


The credit goes to this post: https://github.com/facebook/react-native/issues/20774#issuecomment-424745903. According to it, the third-partydirectory's location is incorrect. 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.

归功于这篇文章:https: //github.com/facebook/react-native/issues/20774#issuecomment-424745903。根据它,third-party目录的位置不正确。它应该是node_modules/react-native/third-party,但是如果您按照此处的某些答案建议运行脚本,则这些依赖项将安装在react-native/scripts/third-party.

回答by Ram S

configure: error: unsafe absolute working directory nameIssue:

配置:错误:不安全的绝对工作目录名称问题:

-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”设置为包含内部文件夹的项目文件夹