如何解决“找不到config.h文件”?从设备上的本机运行app时?

时间:2017-07-13 13:54:07

标签: android ios github react-native react-native-ios

获取错误“找不到Config.h文件,词法或预处理器错误。”

我正在xcode项目的设备中运行应用程序。

我有谷歌并找到了许多解决方案,但没有奏效,我试过这个

https://github.com/facebook/react-native/issues/14382

当我尝试在iOS模拟器中运行时出现此错误

https://github.com/facebook/react-native/issues/10401

试图按照上面的网址但是没有用。

请让我知道如何解决这个问题。 感谢

5 个答案:

答案 0 :(得分:15)

试一试

Open Terminal, go to your project’s root folder and do:
cd node_modules/react-native/third-party/glog-0.3.4/

enter image description here     运行configure脚本:     。/配置 enter image description here     打开Xcode并尝试运行您的应用程序。

Xcode 10

"react-native": "0.57.5"

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

答案 1 :(得分:4)

我遇到了同样的问题,这些命令解决了这个问题: -

纱线

rm -rf node_modules/
yarn clean cache 
yarn install 

NPM

rm -rf node_modules/
npm cache clean  
npm i 

答案 2 :(得分:3)

对我来说:

# rm -rf  node_modules

# npm cache verify  (Because I'm using npm version 5.0.3)

# npm install

Xcode Clean

Xcode Run

如果这不起作用,

在终端中,导航至react-native/third-party/glog folder

内的node_modules

(对我来说,这是cd node_modules/react-native/third-party/glog-0.3.4

一旦积极进入此文件夹,

#run ../../scripts/ios-configure-glog.sh

配置Glog并为config.h创建所需的Xcode头文件以查找

答案 3 :(得分:0)

只需转到config.h文件,单击右侧面板,然后选中正确的案例,将文件添加到应用目标。清理并再次编译。

答案 4 :(得分:0)

删除node_modules / react-native文件夹中的第三方文件夹。