Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS linker error adding Google Nearby Messages API to XCode project #16406

Closed
dimutu-isobar opened this issue Oct 16, 2017 · 4 comments
Closed
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@dimutu-isobar
Copy link

Is this a bug report?

YES

Environment

Environment:
OS: macOS High Sierra 10.13
Node: 8.6.0
Yarn: 1.0.2
npm: 5.3.0
Watchman: 4.7.0
Xcode: Xcode 9.0 Build version 9A235
Android Studio: 2.3 AI-162.4069837

Packages: (wanted => installed)
react: 16.0.0-beta.5 => 16.0.0-beta.5
react-native: 0.49.3 => 0.49.3

Target Platform: iOS (10.0)

Steps to Reproduce

  1. react-native init SampleProject
  2. Follow Google Nearby Messages API installation guide (https://developers.google.com/nearby/messages/ios/get-started) to add Messaging API to react native XCode project
  3. compile XCode workspace project

Expected Behavior

There should not be any duplicated symbols between Google Nearby Messages API implementations with React ThirdParty implementation,
or a work around to avoid the duplication of these symbols to use Google Nearby API in a react native project.

Actual Behavior

Linker error for duplicated symbols.

duplicate symbol __ZN6google10AddLogSinkEPNS_7LogSinkE in:
    /Users/dimutu.k/Library/Developer/Xcode/DerivedData/nearby-axzoinmlhtvrrpfvlpxeomerfvml/Build/Products/Debug-iphoneos/libReact.a(logging.o)
    /Work/WINK/nearby/ios/gns/NearbyMessages/Libraries/libGNSMessages.a(logging.o)
duplicate symbol __ZN6google13RemoveLogSinkEPNS_7LogSinkE in:
    /Users/dimutu.k/Library/Developer/Xcode/DerivedData/nearby-axzoinmlhtvrrpfvlpxeomerfvml/Build/Products/Debug-iphoneos/libReact.a(logging.o)
    /Work/WINK/nearby/ios/gns/NearbyMessages/Libraries/libGNSMessages.a(logging.o)
ld: 2 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Reproducible Demo

Please run

npm install
cd ios
pod install

GNSMessageSampleProject.zip

@matt-oakes
Copy link
Contributor

This is due to duplicate symbols in the glog third party code which seems to also be embedded in NearbyMessages.

A workaround is to rename the symbols in the glog in the React project. You can do this by running these two command:

grep -rl --include \*.h --include \*.cpp --include \*.cc --include \*.in AddLogSink node_modules/react-native/third-party/ | xargs sed -i '' 's/AddLogSink/ReactAddLogSink/g'
grep -rl --include \*.h --include \*.cpp --include \*.cc --include \*.in RemoveLogSink node_modules/react-native/third-party/ | xargs sed -i '' 's/RemoveLogSink/ReactRemoveLogSink/g'

This searches for instances of AddLogSink and RemoveLogSink and replaces them with ReactAddLogSink and ReactRemoveLogSink respectively. As this is done inside node_modules I recommend adding these to your postinstall script to avoid them being overridden every install.

@thebnich
Copy link

thebnich commented Nov 15, 2017

Thanks for the workaround!

Unfortunately, I'm not having any luck using it as a postinstall hook: it seems that node_modules/react-native/third-party doesn't even exist after npm install. Instead, third-party is installed lazily when executing react-native run-ios.

@matt-oakes
Copy link
Contributor

matt-oakes commented Nov 16, 2017 via email

@stale
Copy link

stale bot commented Jan 15, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 15, 2018
@stale stale bot closed this as completed Jan 22, 2018
@facebook facebook locked and limited conversation to collaborators May 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

3 participants