React native glog iOS : Unknown type name '_START_GOOGLE_NAMESPACE_'
Asked Answered
R

4

6

I already built an android project of react native which is working fine. I then started with iOS part. I am using react-native-cli: 2.0.1 react-native: 0.60.4 and Xcode 10 and Mac OS Mojave

The default pod file had some issues installing glog It gave error /bin/bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory when pod install was executed. Even after doing everything answered on GitHub and stack overflow like installing Cocoapods, reinstalling, ruby installation, linking cocoapods. Then later on GitHub I found out that pod file had some issues so replaced it with correct content specified on GitHub for react-native. Still did not work then according to this link : https://forums.expo.io/t/pod-install-errors-on-newly-detached-app-on-macos-installing-glog-bin-bash-configure-bin-sh-m-bad-interpreter-no-such-file-or-directory/10054 and then I modified the glog file and then it installed the glog successfully.

After that another issue with glog Need to implement mutex.h for your architecture, or #define NO_THREADS which I corrected by adding define no_thread in ios/Pods/glog/src/config.h file

And now stuck with this

/Volumes/Projects/derive-mobile/ios/Pods/glog/src/utilities.h:148:1: Unknown type name '_START_GOOGLE_NAMESPACE_' /Volumes/Projects/derive-mobile/ios/Pods/glog/src/utilities.h:168:1: Unknown type name 'int64'; did you mean 'google::int64'? /Volumes/Projects/derive-mobile/ios/Pods/glog/src/utilities.h:170:20: Unknown type name 'int64'; did you mean 'google::int64'? /Volumes/Projects/derive-mobile/ios/Pods/glog/src/utilities.h:175:1: Unknown type name 'int32'; did you mean 'google::int32'? /Volumes/Projects/derive-mobile/ios/Pods/glog/src/utilities.h:236:1: Unknown type name '_END_GOOGLE_NAMESPACE_' /Volumes/Projects/derive-mobile/ios/Pods/glog/src/utilities.h:150:1: Expected unqualified-id

I think my glog installation did not go well. I am using project workspace already.

I have checked overall GitHub Facebook react-native and stack overflow but did not found anything. I have tried legacy build, clearing derived data. I have also tried pod deintegrate and pod install. for glog I have also tried cd ./node_modules/react-native/third-party/glog-0.3.4 && ../../scripts/ios-configure-glog.sh

How can I solve this issue ? is there any way to remove the glog completely and install it again without having the /bin/bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory as none of the solutions works as mentioned above

Rudolph answered 7/8, 2019 at 13:19 Comment(3)
Have you found the answer?Hollywood
You are in the middle of environment hell. Unfortunately, I have fixed this error before, but since it required me to travel down 1000 roads to find the correct fix, I can't remember what I did to fix it. All I can say, beside good luck, is to keep trying - even redoing things you've already done. I think likely the fix involves parts from all the sources you've found - although I never had to modify glog to get it to install, but I did have to try the install many times to get it to work.Gut
One thing I found that sometimes helps, is to not use Cocoapods, and install the dependencies manually from your installed node_modules folder. If you can get rid of enough deps in cocoapods, you may be able to remove react from your cocoapods - I found having it in there screws up pretty much everything. Follow this if you need help with that. facebook.github.io/react-native/docs/linking-libraries-iosGut
D
0

The ./configure file may have been edited in a DOS or Windows environment. (With a notepad, for example). That edition may have added a carriage return (^M or \r) at the end of each line... incompatible in a unix environment.

You can check it by:

$ file ./configure

To re-convert it to unix format you can use dos2unix or edit with vi -b (vi in binary mode).

edit: In ./configure : /bin/sh^M : bad interpreter you have other re-conversion options.

Dna answered 16/8, 2019 at 19:40 Comment(1)
Thank you for your reply. I already tried that, In the link provided in the question but did not work.Rudolph
C
0

I still haven't determined a long term solution to this problem, but I've gotten a little farther than this thread.

Right now, every time after I call a yarn command, I need to update ios-configure-glog.sh to replace these lines:

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

with these lines

dos2unix -f configure
dos2unix -f config.sub
dos2unix -f config.guess
./configure --host arm-apple-darwin
cp {THE FULL PATH TO MY PROJECT}/node_modules/react-native/ReactAndroid/src/main/jni/third-party/glog/config.h src

This fixes all of my glog issues with one fix, but it's not permanent and I don't really want to fork react-native to make it permanent.

Maybe this will point someone else in the right direction to come up with the long term fix. I've narrowed the bad file formatting to those 3 files (configure, config.sub, config.guess) which all seem to reside inside of my Xcode application but appear to use LF line endings so I don't really know how the error is happening.

I might also be removing too much from this file, but I haven't seen any problems related to that.

Cup answered 10/12, 2019 at 19:46 Comment(0)
S
0

I tried dos2unix but honestly, I don't know which file should I apply it to. Because if you do pod install --verbose, you see that glog is being downloaded to a random temporary folder, and built (that's where it fails). So I don't have control.

So, I tried something else. Created a new user in my Mac. Xcode being a shared application. And pod install just worked. No complains. Now, see, the difference in the console outputs seems to point to trunk.

This one is from the new user. It works. enter image description here

There you can see "Adding spec repo trunk"...

Now see my non working command log (from my original user). enter image description here

There's nothing about trunk. And it starts checking the cache, and downloading packages (like glog and Folly). Don't know why. Installing dependencies from the new user was just a breeze.

Hope this hint may lead to a different solution. It may be something about a user setting/configuration. Like UTF-8 or something.

Stig answered 12/12, 2019 at 14:28 Comment(0)
S
0

What fixed it for me was to delete the derived data folder form xcode (xcode->preferences->locations), delete the pod folder from the ios folder and then run the commands

pod cache clean –all, pod repo update (if you use a pod repo) and pod install

Selfexpression answered 17/8, 2020 at 13:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.