React-native: Problems with glog (config.h missing) and gflags/gflags.h on Xcode 10

Created on 17 Jun 2018  路  18Comments  路  Source: facebook/react-native

Environment

Scanning folders for symlinks in .../node_modules (21ms)

  React Native Environment Info:
    System:
      OS: macOS 10.14
      CPU: x64 Intel(R) Core(TM) i7-6567U CPU @ 3.30GHz
      Memory: 1.00 GB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.3.0 - /usr/local/bin/node
      Yarn: 1.7.0 - /usr/local/bin/yarn
      npm: 6.1.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3
    IDEs:
      Xcode: 9.4.1/9F2000 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.3.2 => 16.3.2 
      react-native: 0.56.0-rc.2 => 0.56.0-rc.2 
    npmGlobalPackages:
      create-react-native-app: 1.0.0
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7

Description

Trying to build the initial React Native project is not working on Xcode 10 on Mojave, tested on two machines and had slightly different issues both while compiling glog.

react-native init TestProject --version="0.56.0-rc.2"
cd TestProject
npm run start
react-native run-ios

Fails because 'config.h' file not found on mutex.h. Manually configuring and making glog from node_modules/react-native/third-party/glog-0.3.4 works, but then fails because 'gflags/gflags.h' file not found.

If I try to compile on Xcode 9.4, it also fails. The only thing that enabled me to build on either was:

  1. rm -rf ~/.rncache/
  2. rm -rf $PROJECT/node_modules/react-native/third-party/
  3. Build on Xcode 9.4, passes. Quit Xcode.
  4. Build on Xcode 10, passes.

It is very unstable though, stops working as soon as I reopen Xcode.


I've tested on another machine and had another issue with glog build:

checking for arm-apple-darwin-gcc... /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -arch undefined_arch -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk
checking whether the C compiler works... no
configure: error: in `(..._/node_modules/react-native/third-party/glog-0.3.4':
configure: error: C compiler cannot create executables
See `config.log' for more details

config.log: https://pastebin.com/8M4ybuEp

This machine did not have Xcode installed before. I did install the Command Line Utils.

Reproducible Demo

On macOS Mojave with Xcode 10.

react-native init TestProject --version="0.56.0-rc.2"
cd TestProject
npm run start
react-native run-ios

Fails because 'config.h' file not found on mutex.h.

iOS Locked

Most helpful comment

I had the same issue but manually triggering configure script (cd ./node_modules/react-native/third-party/glog-0.3.4 && ../../scripts/ios-configure-glog.sh) resolves it.

Also - If you want to build app for iOS 12 you have to switch path to the active developer directory (xcode-select -s /Applications/Xcode-beta.app/Contents/Developer).

All 18 comments

I had the same issue but manually triggering configure script (cd ./node_modules/react-native/third-party/glog-0.3.4 && ../../scripts/ios-configure-glog.sh) resolves it.

Also - If you want to build app for iOS 12 you have to switch path to the active developer directory (xcode-select -s /Applications/Xcode-beta.app/Contents/Developer).

I can also confirm this issue appearing when upgrading from RN 0.54 -> 0.56, building using Xcode 10 (or the Xcode 9 Preview Build System).

Like @futuun mentioned, this is resolved by manually triggering the configure script.

It sounds like the new build system isn't running that step by the time it's build artifacts are needed. Where is the ios-configure-glog.sh executed in the RN build process?

In double-conversion and double-conversion-tvOS as part of Install Third Party phase.

Ah, it looks like that script phase should be configured to have the config.h as an output file, so that the new build system knows it needs to run the phase: https://asciiwwdc.com/2018/sessions/408#t=893.696

EDIT: Turns out this isn't true.

I dug into this a bit further today, and it seems as though the ios-configure-glog.sh is never being called as part of ios-install-third-party.sh when using the new build system.

Using set -x inside of ios-install-third-party.sh, I end up with this:

+ cd /Users/eliperkins/src/FixBuild/node_modules/react-native/React/..
+ exec scripts/ios-install-third-party.sh
+ cachedir=/Users/eliperkins/.rncache
+ mkdir -p /Users/eliperkins/.rncache
+ mkdir -p third-party
++ dirname /Users/eliperkins/src/FixBuild/node_modules/react-native/scripts/ios-install-third-party.sh
+ SCRIPTDIR=/Users/eliperkins/src/FixBuild/node_modules/react-native/scripts
+ fetch_and_unpack glog-0.3.4.tar.gz https://github.com/google/glog/archive/v0.3.4.tar.gz 69f91cd5a1de35ead0bc4103ea87294b0206a456 '"/Users/eliperkins/src/FixBuild/node_modules/react-native/scripts/ios-configure-glog.sh"'
+ file=glog-0.3.4.tar.gz
+ url=https://github.com/google/glog/archive/v0.3.4.tar.gz
+ hash=69f91cd5a1de35ead0bc4103ea87294b0206a456
+ cmd='"/Users/eliperkins/src/FixBuild/node_modules/react-native/scripts/ios-configure-glog.sh"'
+ retries=4
+ fetched=no
+ true
+ '[' -f /Users/eliperkins/.rncache/glog-0.3.4.tar.gz ']'
+ shasum -p /Users/eliperkins/.rncache/glog-0.3.4.tar.gz
+ awk -v hash=69f91cd5a1de35ead0bc4103ea87294b0206a456 '{exit $1 != hash}'
+ break
++ basename glog-0.3.4.tar.gz .tar.gz
+ dir=glog-0.3.4
+ '[' no = yes ']'
+ '[' '!' -d third-party/glog-0.3.4 ']'
+ fetch_and_unpack double-conversion-1.1.5.tar.gz https://github.com/google/double-conversion/archive/v1.1.5.tar.gz 96a8aba1b4ce7d4a7a3c123be26c379c2fed1def
+ file=double-conversion-1.1.5.tar.gz
+ url=https://github.com/google/double-conversion/archive/v1.1.5.tar.gz
+ hash=96a8aba1b4ce7d4a7a3c123be26c379c2fed1def
+ cmd=
+ retries=4
+ fetched=no
+ true
+ '[' -f /Users/eliperkins/.rncache/double-conversion-1.1.5.tar.gz ']'
+ shasum -p /Users/eliperkins/.rncache/double-conversion-1.1.5.tar.gz
+ awk -v hash=96a8aba1b4ce7d4a7a3c123be26c379c2fed1def '{exit $1 != hash}'
+ break
++ basename double-conversion-1.1.5.tar.gz .tar.gz
+ dir=double-conversion-1.1.5
+ '[' no = yes ']'
+ '[' '!' -d third-party/double-conversion-1.1.5 ']'
+ fetch_and_unpack boost_1_63_0.tar.gz https://github.com/react-native-community/boost-for-react-native/releases/download/v1.63.0-0/boost_1_63_0.tar.gz c3f57e1d22a995e608983effbb752b54b6eab741
+ file=boost_1_63_0.tar.gz
+ url=https://github.com/react-native-community/boost-for-react-native/releases/download/v1.63.0-0/boost_1_63_0.tar.gz
+ hash=c3f57e1d22a995e608983effbb752b54b6eab741
+ cmd=
+ retries=4
+ fetched=no
+ true
+ '[' -f /Users/eliperkins/.rncache/boost_1_63_0.tar.gz ']'
+ shasum -p /Users/eliperkins/.rncache/boost_1_63_0.tar.gz
+ awk -v hash=c3f57e1d22a995e608983effbb752b54b6eab741 '{exit $1 != hash}'
+ break
++ basename boost_1_63_0.tar.gz .tar.gz
+ dir=boost_1_63_0
+ '[' no = yes ']'
+ '[' '!' -d third-party/boost_1_63_0 ']'
+ fetch_and_unpack folly-2016.10.31.00.tar.gz https://github.com/facebook/folly/archive/v2016.10.31.00.tar.gz fb8cdf8962d8c9d0c20a150b6ec3b75d1fa50696
+ file=folly-2016.10.31.00.tar.gz
+ url=https://github.com/facebook/folly/archive/v2016.10.31.00.tar.gz
+ hash=fb8cdf8962d8c9d0c20a150b6ec3b75d1fa50696
+ cmd=
+ retries=4
+ fetched=no
+ true
+ '[' -f /Users/eliperkins/.rncache/folly-2016.10.31.00.tar.gz ']'
+ shasum -p /Users/eliperkins/.rncache/folly-2016.10.31.00.tar.gz
+ awk -v hash=fb8cdf8962d8c9d0c20a150b6ec3b75d1fa50696 '{exit $1 != hash}'
+ break
++ basename folly-2016.10.31.00.tar.gz .tar.gz
+ dir=folly-2016.10.31.00
+ '[' no = yes ']'
+ '[' '!' -d third-party/folly-2016.10.31.00 ']'

There is no call to exec ios-configure-glog.sh here.

Related to supporting XCode 10, it seems like a PR has been already merged on master: https://github.com/facebook/react-native/pull/19781

If you could verify if it fix it, we can cherry pick it for 0.56 before moving out of RC

No, the PR you linked fixes other issue. You can have few versions of Xcode and switch between them, that PR is for making sure that you are using simulator from active version.

This issue is connected to new build system (@eliperkins linked WWDC transcript). Not sure if we can have changes that will work with Xcode 10 and will be backward compatible with Xcode 9.

Hey @futuun thanks for the detailed clarification :)

Since XCode 10 is still in Beta 1 I feel like then probably 0.56 won't support it, and if the support for it is a breaking change then it will need to be discussed further (this issue I think is a good starting point for this).

Not sure if we can have changes that will work with Xcode 10 and will be backward compatible with Xcode 9.

I'd say the 99% of the issues with the new build system will be backwards compatible.

As far as this issue goes, I've spent a few more minutes look at it, and I'm positive that this is failing on the new build system due to ios-install-third-party.sh never successfully calling ios-configure-glog.sh.

Additionally, this seems extremely related to this commit: https://github.com/facebook/react-native/commit/5c53f89dd86160301feee024bce4ce0c89e8c187#diff-db5be184065c4ffa44ee6585f41e6a69 @janicduplessis @javache

Can someone with more bash script expertise than myself take a look at ios-install-third-party.sh to see what could be causing this? @mhorowitz @fkgozali

cc @hramos, @axe-fb

Also, before ./node_modules/react-native/third-party/glog-0.3.4 && ../../scripts/ios-configure-glog.sh) I run react-native run-ios which downloads glog-0.3.4 (even if it fails to compile).

configure: error: in `/Users/work1/Projects/hablemos/code/hablemos-rn/node_modules/react-native/third-party/glog-0.3.4':

configure: error: C compiler cannot create executables
See `config.log' for more details

Unpacking /Users/work1/.rncache/double-conversion-1.1.5.tar.gz...

Unpacking /Users/work1/.rncache/boost_1_63_0.tar.gz...

Unpacking /Users/work1/.rncache/folly-2016.10.31.00.tar.gz...

I'm running into an issue after applying the change to ios-configure-glog.sh where the src files of double-conversion cannot be found during the compile phase of double-conversion. The project that I'm running is using a version of React Native 51 but I've also tested this by cloning the 56 and 57 stable branches and attempting to build the react target in the React.xcodeproj.

The src files for double-conversion are not finished downloading by the time the compile phase of double-conversion is hit but on a second run of the build target, the build proceeds just fine since the files already exist.

A simple and quick resolution.
In Xcode, go to File->Project/Workspace settings.
Change the build system to Legacy Build system.

Source - https://stackoverflow.com/questions/50718018/xcode-10-error-multiple-commands-produce/50721769

repost from: https://github.com/facebook/react-native/issues/19529#issuecomment-427209573

I wrote something a bit cleaner for my purposes and installed the fix within the node_modules/react-native package. Normally I would prefer not to modify a node_module directly, but under this circumsance I felt that it was worth it and allowed us to add a simple script in our yarn start script and we get a clean run from a fresh clone.

npm install or yarn - install packages
cd node_modules/react-native - go to node modules directory
scripts/ios-install-third-party.sh- install @ node_modules/react-native/third-party
cd third-party - go to newly created third party directory
cd glog-0.3.x - ls -la to find your directory version number or just use tab to auto-complete)
./configure - run setup
cd ../../../../- change back to your project directory
react-native run-ios or react-native run-android - deploy

(maybe its even better inside the node_modules/react-native/node_modules directory?)

A simple and quick resolution.
In Xcode, go to File->Project/Workspace settings.
Change the build system to Legacy Build system.

Source - https://stackoverflow.com/questions/50718018/xcode-10-error-multiple-commands-produce/50721769

Your suggestion works for me! Thanks~

About this question, i have some ideas.

https://github.com/wilddylan/ReactNativeRepairMacOsX

download RepairReactNative.sh and mv to your project root folder.

$ cp RepairReactNative.sh ~/xxx/xxx/your/react/native/project/dir/ 
$ chmod +x RepairReactNative.sh
$ ./RepairReactNative.sh

This might work for people with multiple XCode version

I've had this issue for a week or so and i've tried one of the method mentioned above which asked me to copy the glog and other packages from another package where it works (basically already compiled and kept), but this issue started popping up for other projects as well. Digging deeper i found that there was a error in configuring glog, where it was trying to use compiler from Xcode.app Folder. Unfortunately i've to maintain multiple xcode versions and always named them like XCode XX.X and the glog's .configure was not able to pick this up and it had issue with spacing so it was taking only till /Application/XCode as supposed to /Application/XCode 10.1.app after installing a version of XCode in its defacto location /Application/XCode.app it compiled smoothly.

@kmhari Thank you! You saved my life, i was in exactly the same situation and default configure script didn't help at all. Renaming current XCode XX.X to XCode worked for me

Was this page helpful?
0 / 5 - 0 ratings