Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with glog (config.h missing) and gflags/gflags.h on Xcode 10 #19774

Closed
3 tasks done
WesSouza opened this issue Jun 17, 2018 · 18 comments
Closed
3 tasks done

Problems with glog (config.h missing) and gflags/gflags.h on Xcode 10 #19774

WesSouza opened this issue Jun 17, 2018 · 18 comments
Labels
Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.

Comments

@WesSouza
Copy link

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.

@futuun
Copy link
Contributor

futuun commented Jun 17, 2018

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

@eliperkins
Copy link
Contributor

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?

@futuun
Copy link
Contributor

futuun commented Jun 18, 2018

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

@hramos hramos added the Platform: iOS iOS applications. label Jun 18, 2018
@eliperkins
Copy link
Contributor

eliperkins commented Jun 18, 2018

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.

@eliperkins
Copy link
Contributor

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.

@kelset
Copy link
Contributor

kelset commented Jun 21, 2018

Related to supporting XCode 10, it seems like a PR has been already merged on master: #19781

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

@futuun
Copy link
Contributor

futuun commented Jun 21, 2018

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.

@kelset
Copy link
Contributor

kelset commented Jun 21, 2018

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

@eliperkins
Copy link
Contributor

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: 5c53f89#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

@fkgozali
Copy link
Contributor

cc @hramos, @axe-fb

@gastonmorixe
Copy link

gastonmorixe commented Jun 26, 2018

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

hramos pushed a commit that referenced this issue Jul 4, 2018
Summary:
Fixes #19774

I spotted that in  Xcode 10 beta `CURRENT_ARCH` is set to string `undefined_arch`.  This PR will add fallback based on platform name (simulators are `x86_64` and everything since iPhone 5s is `arm64`).
Closes #19841

Differential Revision: D8619897

Pulled By: hramos

fbshipit-source-id: ed2ebaca105c6dcb40099f1a4aebe34d0660130c
@erenn16
Copy link

erenn16 commented Aug 21, 2018

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.

@akhilsuri02
Copy link

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

@nolindnaidoo
Copy link

repost from: #19529 (comment)

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?)

@baoxiehao
Copy link

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~

@wilddylan
Copy link

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

@kmhari
Copy link

kmhari commented Apr 2, 2019

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.

@Stalder
Copy link

Stalder commented Jun 19, 2019

@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

@facebook facebook locked as resolved and limited conversation to collaborators Jun 28, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jun 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

Successfully merging a pull request may close this issue.