React-native: pod install fails due to glog

Created on 9 Jul 2019  路  64Comments  路  Source: facebook/react-native


When running pod install in my project, it fails with the error:
error: C compiler cannot create executables
Screen Shot 2019-07-09 at 4 13 34 PM

React Native version: 0.60.0

System:
    OS: macOS 10.15
    CPU: (4) x64 Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
    Memory: 4.15 GB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 8.16.0 - ~/.nvm/versions/node/v8.16.0/bin/node
    Yarn: 1.16.0 - ~/.yarn/bin/yarn
    npm: 6.9.1 - ~/.nvm/versions/node/v8.16.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
    Android SDK:
      Android NDK: 19.2.5345600
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5692245
    Xcode: 11.0/11M362v - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6
    react-native: 0.60.0 => 0.60.0
  npmGlobalPackages:
    eslint-plugin-react-native: 3.7.0

I can also reproduce this when not using the beta SDK:

System:
    OS: macOS 10.15
    CPU: (4) x64 Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
    Memory: 4.04 GB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 8.16.0 - ~/.nvm/versions/node/v8.16.0/bin/node
    Yarn: 1.16.0 - ~/.yarn/bin/yarn
    npm: 6.9.1 - ~/.nvm/versions/node/v8.16.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
    Android SDK:
      Android NDK: 19.2.5345600
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5692245
    Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6
    react-native: 0.60.0 => 0.60.0
  npmGlobalPackages:
    eslint-plugin-react-native: 3.7.0

Steps To Reproduce

I found this issue when running pod install in my pre-existing project that I have upgraded to RN 0.60. But, I can reproduce the exact same error when running react-native init test and the error occurs when it gets to pod install

Describe what you expected to happen:
The script not to crash and pod install to finish running

Snack, code example, or link to a repository:
Just do react-native init test and it gives the error

Bug

Most helpful comment

As per https://github.com/facebook/react-native/issues/18408#issuecomment-386696744 (thanks @YuryKorovko !)

sudo xcode-select --switch /Applications/Xcode.app
cd ios && pod install

Fixed!

All 64 comments

This error is the same as #25532, but that issue wasn't formatted well and I couldn't tell what was going on

Looking further into this, the script that is being run is at:
/node_modules/react-native/scripts/ios-configure-glog.sh

If you want to run that script manually, you need to unpack glog-0.3.5 by running
cd node_modules/react-native/scripts/ && ./ios-install-third-party.sh, then copy the configure script into third-party/glog-0.3.5:
cp ios-configure-glog.sh third-party/glog-0.3.5
Then you can run the script and see the crash by running
cd third-party/glog-0.3.5 && ./ios-configure-glog.sh
Screen Shot 2019-07-09 at 4 29 09 PM

Hi @chrisspankroy
I have the same issue here. Run gem update xcodeproj fix this issue. Hope that will work out for you too.

@panyar That did not work for me. Thanks though

Not work for me too. =/

As per https://github.com/facebook/react-native/issues/18408#issuecomment-386696744 (thanks @YuryKorovko !)

sudo xcode-select --switch /Applications/Xcode.app
cd ios && pod install

Fixed!

That did not work for me

any luck with this? i'm having the exact same issue on macOS 10.14.6/Xcode 10.3/RN 0.60

I have, is necessary update pod before install dependencies pods on react native.

Seems to be an issue with Xcode after a new install. I resolved this issue on my machine by:

  1. launch Xcode
  2. from Xcode menu, select Preferences
  3. select Locations tab
  4. select a value for Command Line Tools. Mine was previously blank.

This assumes you've already got command line tools installed.

You may be able to achieve the same result from xcode-select on the command line, but I didn't try that.

That did not work for me

Did you manage to find a solution? Ive tried the above and have this same issue.

Not yet :/

Not really a proper fix, but for future reference to others searching, I found that it was almost certainly due to the way Cocoapods is installed by react-native. I installed Cocoapods separately and after that the bootstrap/build commands started to work for me. (Specifically, I tried another framework (nativescript) and installed Cocoapods using their install script - after which everything worked)

I tried running NativeScript's install script and it did not fix it :(

Did the Cocoapods install definitely succeed? It doesnt have to be through Nativescript's installer I don't think.

Yeah, I鈥檝e made sure it succeeds. I鈥檝e ran CocoaPods鈥檚 own installer too and nothing

This looks like a problem with glog or my environment.
I was download glog and try to install it separately.
When I run ./configure under the glog folder, there is the same problem as react-native project.

Finally, I found a way to solve the failure of installing glog, just run install script as root, sudo ./configure

Unfortunately, pod install does not support running as root.

I am still having this issue

update

This was my error output:
Screen Shot 2019-09-22 at 1 03 04 AM

The important part was
dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib

I resolved it by following these instructions (from https://stackoverflow.com/questions/54261455/library-not-loaded-usr-local-opt-readline-lib-libreadline-7-dylib):
cd /usr/local/opt/readline/lib
ln -s libreadline.8.0.dylib libreadline.7.dylib

@BelinChung I'm facing the exact same issue, it seems that my glog requires sudo to configure and make. Because of that pod install always fails. I've downgraded react native from 0.60.5 to 0.59.10 and the same issue persists, I've uninstalled and reinstalled different versions of Xcode (11, 10.3, 10.1) and they all seem to fail.

Just an update:
I still haven鈥檛 found a solution to this, but adding sudo to the configure script to get it to work isn鈥檛 a solution. Sure it might get the configure script to work, but it messes up your file permissions and doesn鈥檛 even help solve the actual problem :/

Update:
馃帀 Good news here, It seems that [email protected] solves this problem. Official init demo is working for me now.

Updating to 0.61.1 did not work for me :(

I tried react-native getting started's React Native CLI Quickstart for MacOS for iOS
https://facebook.github.io/react-native/docs/getting-started.html
and confirm that AwesomeProject did not install, again because of glog

So I experimented and found out something that allowed me to install the example AwesomeProject. I created a new user on Mac and made the user admin. Then I logged out my normal user account and logged in as the new user, and followed the instructions. The example app failed to install at installing the pods state, but not for the same reason as my main user. Then I did sudo xcode-select --reset and did pod install and it worked!

I tried sudo xcode-select --reset with my normal user account and I am still failing with installing glog however.

@chrisspankroy
I figured it out. It is the environment variables. I had LDFLAGS and CPPFLAGS set. After unsetting those, the pod installation worked.

Whoop, whoop, that finally worked! Great job, I'll close the issue now. Feel free to reopen if this comes up again

@yaizudamashii How do you unset those variables?

Depends how they were set :) In my case, I set them in my zshrc file (I use the zsh shell)

Ok thanks @chrisspankroy. After dealing with this for a whole day I just rebooted my system and it went away

Hello i use window so far your solution

sudo xcode-select --switch /Applications/Xcode.app

I use window and currently i was detaching expo from my project and pod install bring error during install glog tha scropt is too old or missing so how can i fix that and cant run sudo command in window

That command is MacOS-specific, it鈥檚 not valid on Windows. My suggestion would be to check if you have those compiler flags set (LDFLAGS and CPPFLAGS) and unset them if you do. But, I鈥檓 not on Windows so I don鈥檛 know if that will have any effect.

I also don鈥檛 know much about Expo, but my understanding is that once you eject, you have to compile the app yourself, and I don鈥檛 think you can compile a native iOS app on Windows. I could be wrong though, someone please correct me if I am

I had almost same error log and I could find the error with the path in config.log.
So in my case, the problem existed in Xcode's path.

I had two Xcode installed and they were placed like _/Applications/Xcode 10.3.app_ and _/Application/Xcode 11.1.app_ which caused the problem because of space in the path.

After renaming the selected Xcode to _/Application/Xcode.app_, it works!

@chrisspankroy
I figured it out. It is the environment variables. I had LDFLAGS and CPPFLAGS set. After unsetting those, the pod installation worked.

This solution works on my machine, and it's because I rewrite those env var for llvm

Since macOS encourages ZSH, I think a lot of mac users may fall into this trap. In setting up the z-shell (zsh), ~/.zprofile is made. Somehow, I have these 2 lines in the file:

export LDFLAGS="-L/usr/local/opt/llvm/lib"
export CPPFLAGS="-I/usr/local/opt/llvm/include"

As @yaizudamashii has said, unset them: Delete or comment those lines in the file using: vim ~/.zprofile!

Restarting my computer then run pod install again fixed the problem for me. It should be noted that I did run sudo xcode-select --switch /Applications/Xcode.app first.

Restarting my computer then run pod install again fixed the problem for me. It should be noted that I did run sudo xcode-select --switch /Applications/Xcode.app first.

It worked for me !!

update

This was my error output:
Screen Shot 2019-09-22 at 1 03 04 AM

The important part was
dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib

I resolved it by following these instructions (from https://stackoverflow.com/questions/54261455/library-not-loaded-usr-local-opt-readline-lib-libreadline-7-dylib):
cd /usr/local/opt/readline/lib
ln -s libreadline.8.0.dylib libreadline.7.dylib

This solved my problem. Now running pod install works like a charm!! Thanks!

Seems to be an issue with Xcode after a new install. I resolved this issue on my machine by:

  1. launch Xcode
  2. from Xcode menu, select Preferences
  3. select Locations tab
  4. select a value for Command Line Tools. Mine was previously blank.

This assumes you've already got command line tools installed.

You may be able to achieve the same result from xcode-select on the command line, but I didn't try that.

Thanks a lot, it really helps me to solve my issue.

sudo xcode-select --switch /Applications/Xcode.app

Worked for me no restart needed

Since macOS encourages ZSH, I think a lot of mac users may fall into this trap. In setting up the z-shell (zsh), ~/.zprofile is made. Somehow, I have these 2 lines in the file:

export LDFLAGS="-L/usr/local/opt/llvm/lib"
export CPPFLAGS="-I/usr/local/opt/llvm/include"

As @yaizudamashii has said, unset them: Delete or comment those lines in the file using: vim ~/.zprofile!

That solved my problem

Conforme # 18408 (coment谩rio) (obrigado @YuryKorovko !)

sudo xcode-select --switch /Applications/Xcode.app
cd ios && pod install

Fixo!

Its works for me, thanks

I change Xcode command line tools to Xcode 11.2.1 issue was fixed. May be same your issue.

sudo xcode-select --switch /Applications/Xcode.app worked for me also, thank you all.

please got to ios folder and run this command sudo xcode-select --switch /Applications/Xcode.app

~/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6 ((v0.3.5)): $>sudo ./configure
Ran perfectly, but still got an error when I ran pod install.
@BelinChung

For others, I had to go to ~/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6 to see the config.log
CXXCPP was set to /lib/cpp
to test I ran export CXXCPP=/usr/bin/cpp
This resolved, so I added it to my ~/.bashrc

For me, I had the CPATH env variable set in my .bash_profile. This was confirmed by running printenv and looking for CPATH.

By removing/unsetting the CPATH variable from my .bash_profile and then closing/reopening my terminal window, the problem was fixed.

Thanks @cchamb-gh

Seems to be an issue with Xcode after a new install. I resolved this issue on my machine by:

  1. launch Xcode
  2. from Xcode menu, select Preferences
  3. select Locations tab
  4. select a value for Command Line Tools. Mine was previously blank.

This assumes you've already got command line tools installed.

You may be able to achieve the same result from xcode-select on the command line, but I didn't try that.

As a side note, if you have more than one Xcode installation and one of them has whitespaces in it's name, Xcode 11.3.app as an example, it would give you the same error.

Rename your instance of Xcode in Applications folder, select the new file:

sudo xcode-select --switch /Applications/<NewName>.app

and it should work nicely. :)

Thanks @scttmthsn It worked!

On /Application/Xcode.app --> Make sure your it's Xcode.app. I've done lots of R & D on this. In my case, I had multiple Xcodes on my mac, so I've renamed it to like Xcode 11.4.1.app & Xcode 10.4.app, So I renamed the Xcode 11.4.1.app to Xcode.app, and boom, It's worked!!!

As per #18408 (comment) (thanks @YuryKorovko !)

sudo xcode-select --switch /Applications/Xcode.app
cd ios && pod install

Fixed!

that work for me

Seems to be an issue with Xcode after a new install. I resolved this issue on my machine by:

  1. launch Xcode
  2. from Xcode menu, select Preferences
  3. select Locations tab
  4. select a value for Command Line Tools. Mine was previously blank.

This assumes you've already got command line tools installed.

You may be able to achieve the same result from xcode-select on the command line, but I didn't try that.

For me this worked. It was a brand new XCode installation I was working with.

As per #18408 (comment) (thanks @YuryKorovko !)

sudo xcode-select --switch /Applications/Xcode.app
cd ios && pod install

Fixed!

thanks a lot. It worked.

I faced a similar issue with Flipper-GLog dependency, I was using macOS Catalina (with XCode 11)
Below steps helped me to resolve this issue:

  1. Rename the Xcode app name, make sure the app name does not include space character.(Xcode 11.app to Xcode11.app)
  2. Switch to the Xcode with sudo xcode-select --switch
    sudo xcode-select -switch /Applications/Xcode11.app/
  3. Pod install

As per #18408 (comment) (thanks @YuryKorovko !)

sudo xcode-select --switch /Applications/Xcode.app
cd ios && pod install

Fixed!

it's not working

image

I am using windows and getting this problem after this
image

For anyone that ends up here and has the same issue I had (error log below).

I got a brand new MacBook Pro and started having the issue below on react-native fresh install when trying to run pod install but after following this comment things got back to normal.

[!] /bin/bash -c
set -e
#!/bin/bash
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

set -e

PLATFORM_NAME="${PLATFORM_NAME:-iphoneos}"
CURRENT_ARCH="${CURRENT_ARCH}"

if [ -z "$CURRENT_ARCH" ] || [ "$CURRENT_ARCH" == "undefined_arch" ]; then
    # Xcode 10 beta sets CURRENT_ARCH to "undefined_arch", this leads to incorrect linker arg.
    # it's better to rely on platform name as fallback because architecture differs between simulator and device

    if [[ "$PLATFORM_NAME" == *"simulator"* ]]; then
        CURRENT_ARCH="x86_64"
    else
        CURRENT_ARCH="armv7"
    fi
fi

export CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)"
export CXX="$CC"

# Remove automake symlink if it exists
if [ -h "test-driver" ]; then
    rm test-driver
fi

./configure --host arm-apple-darwin

# Fix build for tvOS
cat << EOF >> src/config.h
/* Add in so we have Apple Target Conditionals */
#ifdef __APPLE__
#include <TargetConditionals.h>
#include <Availability.h>
#endif
/* Special configuration for AppleTVOS */
#if TARGET_OS_TV
#undef HAVE_SYSCALL_H
#undef HAVE_SYS_SYSCALL_H
#undef OS_MACOSX
#endif
/* Special configuration for ucontext */
#undef HAVE_UCONTEXT_H
#undef PC_FROM_UCONTEXT
#if defined(__x86_64__)
#define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip
#elif defined(__i386__)
#define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip
#endif
EOF

# Prepare exported header include
EXPORTED_INCLUDE_DIR="exported/glog"
mkdir -p exported/glog
cp -f src/glog/log_severity.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/raw_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/stl_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/vlog_is_on.h "$EXPORTED_INCLUDE_DIR/"

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-apple-darwin-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for arm-apple-darwin-gcc... /Library/Developer/CommandLineTools/usr/bin/cc -arch armv7 -isysroot
checking whether the C compiler works... no
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: unable to lookup item 'Path' in SDK 'iphoneos'
/Users/michaellancaster/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6/missing: Unknown `--is-lightweight' option
Try `/Users/michaellancaster/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
configure: error: in `/Users/michaellancaster/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6':
configure: error: C compiler cannot create executables
See `config.log' for more details

Seems to be an issue with Xcode after a new install. I resolved this issue on my machine by:

  1. launch Xcode
  2. from Xcode menu, select Preferences
  3. select Locations tab
  4. select a value for Command Line Tools. Mine was previously blank.

This assumes you've already got command line tools installed.

You may be able to achieve the same result from xcode-select on the command line, but I didn't try that.

Solved

I have exactly the same issue and I tried each solution, except unsetting LDFLAGS and CPPFLAGS variables because I don't find them. I searched in ~/.bashrc, ~/.bash_profile, and ~/.profile. I don't use zsh, but should I install it ? Thanks for your help.

I solved the problem with $ sudo xcode-select --switch /Applications/Xcode.app. Important: restart your terminal after executing this command ! Then you can do cd ios && pod install

As per #18408 (comment) (thanks @YuryKorovko !)

sudo xcode-select --switch /Applications/Xcode.app
cd ios && pod install

Fixed!

thanks a lot. It helped.

Restarting my computer then run pod install again fixed the problem for me. It should be noted that I did run sudo xcode-select --switch /Applications/Xcode.app first.

Thanks! This worked for me

Was this page helpful?
0 / 5 - 0 ratings