Problems with glog (config.h missing) and gflags/gflags.h on Xcode 10
See original GitHub issue- 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
.
Issue Analytics
- State:
- Created 5 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?)