react-native: Problems with glog (config.h missing) and gflags/gflags.h on Xcode 10
- Review the documentation: https://facebook.github.io/react-native
- Search for existing issues: https://github.com/facebook/react-native/issues
- Use the latest React Native release: https://github.com/facebook/react-native/releases
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:
rm -rf ~/.rncache/
rm -rf $PROJECT/node_modules/react-native/third-party/
- Build on Xcode 9.4, passes. Quit Xcode.
- 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
.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 20
- Comments: 18 (8 by maintainers)
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
).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
oryarn
- install packagescd node_modules/react-native
- go to node modules directoryscripts/ios-install-third-party.sh
- install @ node_modules/react-native/third-partycd third-party
- go to newly created third party directorycd glog-0.3.x
-ls -la
to find your directory version number or just use tab to auto-complete)./configure
- run setupcd ../../../../
- change back to your project directoryreact-native run-ios
orreact-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
About this question, i have some ideas.
https://github.com/wilddylan/ReactNativeRepairMacOsX
download
RepairReactNative.sh
and mv to your project root folder.Your suggestion works for me! Thanks~
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.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.
Also, before
./node_modules/react-native/third-party/glog-0.3.4 && ../../scripts/ios-configure-glog.sh)
I runreact-native run-ios
which downloadsglog-0.3.4
(even if it fails to compile).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 callingios-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