32

In X-Code project of react native, getting error

config.h file not found.

Here is version detail :

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

How to solve it?

Star
  • 3,222
  • 5
  • 32
  • 48
Jagdeep Singh
  • 2,556
  • 3
  • 18
  • 28

10 Answers10

91
  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.

Ronan Boiteau
  • 9,608
  • 6
  • 34
  • 56
John Marshall
  • 921
  • 5
  • 2
  • 2
    ...and this is happening consistently after creating a new prj with ```react-native-cli: 2.0.1 react-native: 0.55.4``` - this being the only fix, thanks! – Edoardo May 16 '18 at 12:55
  • 1
    Getting this error: checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... configure: error: unsafe absolute working directory name – Amber K Jun 28 '18 at 12:49
  • Perfect. Worked for me. – mediaguru Nov 10 '18 at 05:35
  • Just had to do this again. How often does this happen. – mediaguru Nov 13 '18 at 00:42
  • **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 – Ram S Nov 13 '18 at 10:13
  • Ram S can you clarify your comment? You are setting the project folder to 777? – mediaguru Nov 25 '18 at 22:57
  • I am getting "checking whether build environment is sane... configure: error: unsafe absolute working directory name" after running ./configure – Nick Feb 21 '19 at 11:08
12

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:

  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)
  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
  3. Run your iOS BUILD

Regards!

Deivison Sporteman
  • 2,334
  • 1
  • 19
  • 22
  • Getting this error: checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... configure: error: unsafe absolute working directory name – Amber K Jun 28 '18 at 12:49
  • You can really just do this from your project's root directory: `./node_modules/react-native/scripts/ios-configure-glog.sh` – Justin Noel Oct 16 '18 at 13:19
6

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
Arjun Vyas
  • 27
  • 7
Gavin Thomas
  • 1,827
  • 2
  • 11
  • 17
  • I just ran into this, too. Only difference was that I needed node_modules reinstalled before I could run the react-native upgrade command. – tamouse Mar 14 '18 at 02:47
3

These steps worked for me:

rm -rf ~/.rncache
rm -rf node_modules/
npm install
npm start
yogevbd
  • 1,548
  • 1
  • 14
  • 18
3

You need to change to the legacy build system in Xcode 10 and install third party scripts manually.

1:

File -> Project/Workspace settings Build System: dropdown -> change to Legacy Build system

2: Follow this to manually install third party scripts for RN:

Clean RN cache

$ rm -rf ~/.rncache

Re-install the deps

$ 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

Run the commands below if glog installation failed.

$ cd ../third-party/glog-0.3.x $ ./configure

It works for me, I hope it helps for you.

Minhaj Javed
  • 913
  • 8
  • 20
2

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.

While in terminal, it accepts throgh My Disk as My\ Disk but xcode do not recognize that.

If its in My Disk directory, try after moving it to Desktop or any other directory which doesn't have space in their name.

imrohan
  • 21
  • 2
0

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:

./configure

got error: configure: error: unsafe absolute working directory name

try to created app in desktop and from there run ./configure command.

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

Ram S
  • 793
  • 12
  • 21
0

This is the linking issue in 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.
  2. Open React.xcodeproj file in xcode.
  3. You will see missing (showing red in color) files under the third-party folder
  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.

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.

Naresh
  • 869
  • 8
  • 17
0

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

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.

Sandeep Rajbhar
  • 93
  • 1
  • 10
0

Although the already mentioned answers are correct but still few guys are struggling, as only configuring the glog doesn't sometimes resolve the error. Here I have written a detailed solution to the problem.

Solution: config.h file not found mutex.h During Archive.

The steps are the following:

  1. Remove node_modules directory
  2. Clear Cache
  3. Install packages again with Yarn
  4. Install third party
  5. Configure Glog
  6. Make & Make install 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.

Asad Ali Choudhry
  • 4,985
  • 4
  • 31
  • 36