C compiler cannot create executables (installing Cocoapods)
Asked Answered
W

8

20

While installing RNPermissions and its dependencies I run into an error. Seems to be a problem with my compiler or the package that is being installed.

The error:

checking whether the C compiler works... no
/Users/si/Library/Caches/CocoaPods/Pods/Release/glog/0.3.4-1de0b/missing: Unknown `--is-lightweight' option
Try `/Users/si/Library/Caches/CocoaPods/Pods/Release/glog/0.3.4-1de0b/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
configure: error: in `/Users/si/Library/Caches/CocoaPods/Pods/Release/glog/0.3.4-1de0b':
configure: error: C compiler cannot create executables
See `config.log' for more details

Full output:

$ pod install
Analyzing dependencies
Fetching podspec for `Folly` from `../node_modules/react-native/third-party-podspecs/Folly.podspec`
Fetching podspec for `Permission-Camera` from `../node_modules/react-native-permissions/ios/Camera.podspec`
Fetching podspec for `Permission-LocationAlways` from `../node_modules/react-native-permissions/ios/LocationAlways.podspec`
Fetching podspec for `Permission-LocationWhenInUse` from `../node_modules/react-native-permissions/ios/LocationWhenInUse.podspec`
Fetching podspec for `RNPermissions` from `../node_modules/react-native-permissions`
Fetching podspec for `React` from `../node_modules/react-native/`
Fetching podspec for `yoga` from `../node_modules/react-native/ReactCommon/yoga`
Downloading dependencies
Installing DoubleConversion (1.1.5)
Installing Folly (2018.10.22.00)
Using RNPermissions (2.0.3)
Using React (0.59.10)
Installing boost-for-react-native (1.63.0)
Installing glog (0.3.4)
[!] /bin/bash -c 
set -e
#!/bin/bash
set -e

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

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

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... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -arch undefined_arch -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk
checking whether the C compiler works... no
/Users/si/Library/Caches/CocoaPods/Pods/Release/glog/0.3.4-1de0b/missing: Unknown `--is-lightweight' option
Try `/Users/si/Library/Caches/CocoaPods/Pods/Release/glog/0.3.4-1de0b/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
configure: error: in `/Users/si/Library/Caches/CocoaPods/Pods/Release/glog/0.3.4-1de0b':
configure: error: C compiler cannot create executables
See `config.log' for more details
Welcher answered 22/11, 2019 at 17:13 Comment(1)
Hi Peter G what is your solution to fix this issues?Halfblood
W
0

Updated GCC and the problem went away.

brew update
brew upgrade
brew info gcc
brew install gcc
brew cleanup
Welcher answered 25/11, 2019 at 13:47 Comment(0)
H
50

Open Xcode

  1. Select Xcode goto Preferences...

Select **Xcode** goto **Preferences...**

  1. Select Loctions and set Command Line Tools

Select **Loctions** and set **Command Line Tools**

Herniorrhaphy answered 17/6, 2020 at 21:16 Comment(1)
I solved my issue with this!Indifferentism
S
19

For me running sudo xcode-select --reset fixed it.

Additionally you may need to run first brew install gcc or brew upgrade gcc.

Sidekick answered 18/4, 2020 at 16:38 Comment(3)
I don't think GCC is related. xcode reset should fix it.Aminopyrine
Does xcode use GCC by default, or a separate compiler?Drover
The [$ brew install gcc] solved the problem for meUchida
S
6

Set your XCODE CLI via XCode preferences and then run pod install again.

Xcode -> Preferences -> Locations -> Command Line Tools

Scruple answered 7/9, 2020 at 6:27 Comment(0)
P
5

Had the same issue, slightly different output. Resolved by accepting Xcode license sudo xcodebuild -license accept

Paulson answered 16/5, 2020 at 16:44 Comment(1)
OMG THIS WORKED! I have literally been trying to fix this for WEEKS. WEEKS. Thank you smMaim
A
5

An edge case that caused this error for me is where the Xcode application path has a blank space in it.

In my case I had to rename /Applications/Xcode\ 14.2.app to /Applications/Xcode14.2.app, and of course update Xcode's location with sudo xcode-select -s /Applications/Xcode14.2.app.

Archean answered 6/9, 2023 at 12:45 Comment(0)
D
2

Ensure Xcode is in your Applications folder.

I had to install an old version of Xcode and was just running it out of ~/Downloads. Once I moved (cut/paste) the Xcode.app file to Applications, this error went away.

Source: https://www.ryadel.com/en/xcode-sdk-iphoneos-cannot-be-located-mac-osx-error-fix/

Dozer answered 9/12, 2021 at 10:0 Comment(1)
I had a similar situation going on. Instead of the executable being named "Xcode.app" is was named "Xcode 13.app", which meant the compilation process was not able to find it. Renaming from "Xcode 13" to "Xcode" solved my problem.Diminutive
F
2

I tried the laundry list of suggestions, and found a non-ideal workaround from here: https://github.com/facebook/react-native/issues/32291#issuecomment-929965479

I executed which gcc and used that path on the export CC line in the script referenced above.

Of course, editing directly in node_modules isn't the best way to do it, as it'll be blown away with any updates, but it at least allowed the pod install to complete.

Frankpledge answered 1/9, 2022 at 14:13 Comment(2)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Godhood
This worked for me. I simply did brew install gcc and then sed -i 's|CC=.*|CC="gcc"|' node_modules/react-native/scripts/ios-configure-glog.sh in my project root. Note that I'm using GNU sed 4.8.Gothart
W
0

Updated GCC and the problem went away.

brew update
brew upgrade
brew info gcc
brew install gcc
brew cleanup
Welcher answered 25/11, 2019 at 13:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.