react-native icon indicating copy to clipboard operation
react-native copied to clipboard

duplicate symbols for architecture x86_64 React Ntaive version 0.64

Open CRathod1220 opened this issue 4 years ago • 36 comments

I got this when build with latest version of react-native

duplicate symbol 'folly::detail::str_to_bool(folly::Range<char const*>)' in: /Users/charlier/Library/Developer/Xcode/DerivedData/BanjaraWedding-hhgkttbaoprqvgftffbbkscdmncr/Build/Products/Debug-iphonesimulator/Flipper-Folly/libFlipper-Folly.a(Conv.o) /Users/charlier/Library/Developer/Xcode/DerivedData/BanjaraWedding-hhgkttbaoprqvgftffbbkscdmncr/Build/Products/Debug-iphonesimulator/RCT-Folly/libRCT-Folly.a(Conv.o) duplicate symbol 'folly::makeConversionError(folly::ConversionCode, folly::Range<char const>)' in: /Users/charlier/Library/Developer/Xcode/DerivedData/BanjaraWedding-hhgkttbaoprqvgftffbbkscdmncr/Build/Products/Debug-iphonesimulator/Flipper-Folly/libFlipper-Folly.a(Conv.o) /Users/charlier/Library/Developer/Xcode/DerivedData/BanjaraWedding-hhgkttbaoprqvgftffbbkscdmncr/Build/Products/Debug-iphonesimulator/RCT-Folly/libRCT-Folly.a(Conv.o) ld: 2 duplicate symbols for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

1.react-native: 0.64 2.xcode :12.5.1 3.React :17

#PodFile look like

platform :ios, '10.0' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' require_relative '../node_modules/react-native/scripts/react_native_pods'

def flipper_pods() flipperkit_version = '0.90.0' pod 'FlipperKit', '~>' + flipperkit_version, :configuration => 'Debug' pod 'FlipperKit/FlipperKitLayoutPlugin', '~>' + flipperkit_version, :configuration => 'Debug' pod 'FlipperKit/SKIOSNetworkPlugin', '~>' + flipperkit_version, :configuration => 'Debug' pod 'FlipperKit/FlipperKitUserDefaultsPlugin', '~>' + flipperkit_version, :configuration => 'Debug' pod 'FlipperKit/FlipperKitReactPlugin', '~>' + flipperkit_version, :configuration => 'Debug' end

def flipper_post_install(installer) file_name = Dir.glob("*.xcodeproj")[0] app_project = Xcodeproj::Project.open(file_name) app_project.native_targets.each do |target| target.build_configurations.each do |config| cflags = config.build_settings['OTHER_CFLAGS'] || '$(inherited) ' unless cflags.include? '-DFB_SONARKIT_ENABLED=1' puts 'Adding -DFB_SONARKIT_ENABLED=1 in OTHER_CFLAGS...' cflags << '-DFB_SONARKIT_ENABLED=1' end config.build_settings['OTHER_CFLAGS'] = cflags end app_project.save end installer.pods_project.save end

target 'Example' do pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector" pod 'FBReactNativeSpec', :path => "../node_modules/react-native/React/FBReactNativeSpec" pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired" pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety" pod 'React', :path => '../node_modules/react-native/' pod 'React-Core', :path => '../node_modules/react-native/' pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules' pod 'React-Core/DevSupport', :path => '../node_modules/react-native/' pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS' pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation' pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob' pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image' pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS' pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network' pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings' pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text' pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration' pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'

pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact' pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi' pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor' pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector' pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon" pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga' pod 'React-perflogger', :path => '../node_modules/react-native/ReactCommon/reactperflogger' pod 'React-runtimeexecutor', :path => '../node_modules/react-native/ReactCommon/runtimeexecutor' pod 'react-native-fbsdk', :path => '../node_modules/react-native-fbsdk'

pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec' pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec' pod 'RCT-Folly', :podspec => '../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec' pod 'Google-Mobile-Ads-SDK' pod 'React-callinvoker', :path => "../node_modules/react-native/ReactCommon/callinvoker"

flipper_pods() pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'

pod 'FBReactNativeSpec', :path => "../node_modules/react-native/React/FBReactNativeSpec"

pod 'react-native-image-picker', :path => '../node_modules/react-native-image-picker'

post_install do |installer| flipper_post_install(installer) end target 'ExampleTests' do inherit! :search_paths # Pods for testing end

use_native_modules! end

CRathod1220 avatar Aug 15 '21 09:08 CRathod1220

Getting the same with RN 0.65

marcosrdz avatar Aug 18 '21 05:08 marcosrdz

For me, use_flipper!({ "Flipper-DoubleConversion" => "1.1.7" }) in Podfile fixed this.

wjaykim avatar Aug 18 '21 13:08 wjaykim

Same here

hahtml avatar Aug 31 '21 10:08 hahtml

The duplicate symbol message appears too when building on RN 0.66, but it doesn't cause the build to fail.

From the build logs:

▸ Running script '[CP] Check Pods Manifest.lock'
▸ Linking MyApp\
⚠️  ld: duplicate symbol 'folly::detail::str_to_bool(folly::Range<char const*>*)' in:
⚠️  ld: duplicate symbol 'folly::makeConversionError(folly::ConversionCode, folly::Range<char const*>)' in:
⚠️  ld: duplicate symbol 'folly::exception_wrapper::from_exception_ptr(std::exception_ptr&&)' in:
⚠️  ld: duplicate symbol 'folly::exception_wrapper::from_exception_ptr(std::exception_ptr const&)' in:
⚠️  ld: duplicate symbol 'folly::exception_wrapper::onNoExceptionError(char const*)' in:
⚠️  ld: duplicate symbol 'folly::exceptionStr(folly::exception_wrapper const&)' in:
⚠️  ld: duplicate symbol 'folly::exception_wrapper::uninit_' in:
⚠️  ld: duplicate symbol 'folly::exception_wrapper::ExceptionPtr::ops_' in:
⚠️  ld: duplicate symbol 'folly::exception_wrapper::SharedPtr::ops_' in:
▸ Running script 'Bundle React Native code and images'
    the transform cache was reset.

fiznool avatar Oct 06 '21 12:10 fiznool

Still having this error with React Native 0.66.1

For me, use_flipper!({ "Flipper-DoubleConversion" => "1.1.7" }) in Podfile fixed this.

This solves here

Installing Flipper-DoubleConversion 1.1.7 (was 3.1.7)

akinncar avatar Oct 17 '21 15:10 akinncar

After upgrading XCode & RN I got the same error. I'm not sure if my project settings are different than @fiznool which is why I'm getting an error and not a warning, but @wjaykim fix worked for me as well.

React 17.0.2 React-Native 0.66.3 XCode 13.1

jefawks3 avatar Nov 19 '21 16:11 jefawks3

Get the same error with React-Native 0.66.3 and the tipp…

For me, use_flipper!({ "Flipper-DoubleConversion" => "1.1.7" }) in Podfile fixed this.

from @wjaykim solved it. 😎🙏

tscharke avatar Nov 26 '21 11:11 tscharke

Apparently altering DEAD_CODE_STRIPPING setting (to either remove a 'NO' setting from pbxproj.proj, or add a 'YES' value for this setting) will resolve this. Experimental results from people that test this would be welcome.

https://stackoverflow.com/a/69565059/9910298

mikehardy avatar Mar 13 '22 17:03 mikehardy

Apparently altering DEAD_CODE_STRIPPING setting (to either remove a 'NO' setting from pbxproj.proj, or add a 'YES' value for this setting) will resolve this. Experimental results from people that test this would be welcome.

https://stackoverflow.com/a/69565059/9910298

Worked for me! Thanks

alfonsojbro avatar May 17 '22 17:05 alfonsojbro

Apparently altering DEAD_CODE_STRIPPING setting (to either remove a 'NO' setting from pbxproj.proj, or add a 'YES' value for this setting) will resolve this. Experimental results from people that test this would be welcome.

Setting the debug value to "YES" resolved this issue for me.

Screen Shot 2022-06-04 at 9 41 17 AM

Thanks @mikehardy – you're in a bunch of the troubleshooting threads I come across and you seem to always have the answer along with an explanation. Much appreciated as always! 🙇

chrisheninger avatar Jun 04 '22 16:06 chrisheninger

@chrisheninger turns out maintaining a bunch of popular repos is less about adding features and more about just figuring out compile errors for everyone - an unexpected result but that explains my presence in all the compile errors threads. Wish I could generate the fixes in non-regressive-for-other-cases ways and get people to upgrade to the versions with fixes though. Mostly these days all the compile issues are sorted out but some people are on old versions or we don't have an upstream fix we're 100% sure on yet. Bit by bit we get it working though...

mikehardy avatar Jun 04 '22 20:06 mikehardy

Has anyone that has either a) removed DEAD_CODE_STRIPPING = NO; or b) changed the value to YES noticed any implications from this? I can't quite figure out what it does (although, judging from the name I can take a guess! 😄). But removing it seems to work.

nialldbarber avatar Jun 16 '22 07:06 nialldbarber

I have not heard any negatives of setting it to NO but there is of course the direct negative implication that your final .ipa will be larger.

Negative of not specifying the flag or setting it to YES is that you cannot even compile for macCatalyst+Flipper, so it's a hard stop on developing. Other use cases in this thread indicate there may be other situations it leads to build-time link failure.

I just attempted to read through known literature on the subject and it turns out there is a sub-flag that may work for those affected. What is it?

It's turning DEAD_CODE_STRIPPING to YES (which previously would crash macCatalyst + Flipper builds, at least) but then turn PRESERVE_DEAD_CODE_INITS_AND_TERMS to YES (normally it would default to NO).

Maybe that allows things to still work but diminishes the size impact of not even attempting to determine dead code and strip it at link time. Unknown, test results would be needed.

mikehardy avatar Jun 16 '22 12:06 mikehardy

It's turning DEAD_CODE_STRIPPING to YES (which previously would crash macCatalyst + Flipper builds, at least) but then turn PRESERVE_DEAD_CODE_INITS_AND_TERMS to YES (normally it would default to NO).

It seems this doesn't work, I get an error saying: ld: option -no_dead_strip_inits_and_terms is obsolete and being ignored and then all the duplicate symbol errors.

ibobo avatar Jun 20 '22 14:06 ibobo

Setting DEAD_CODE_STRIPPING and PRESERVE_DEAD_CODE_INITS_AND_TERMS to YES has fixed the duplicate symbol errors. I'll come back with more information (if any) when I have it.

nialldbarber avatar Jun 20 '22 14:06 nialldbarber

Never mind... I had a different issue that prevented the build from working.

ibobo avatar Jun 20 '22 15:06 ibobo

Apparently altering DEAD_CODE_STRIPPING setting (to either remove a 'NO' setting from pbxproj.proj, or add a 'YES' value for this setting) will resolve this. Experimental results from people that test this would be welcome.

Setting the debug value to "YES" resolved this issue for me.

Screen Shot 2022-06-04 at 9 41 17 AM

Thanks @mikehardy – you're in a bunch of the troubleshooting threads I come across and you seem to always have the answer along with an explanation. Much appreciated as always! 🙇

in my case its previously yes selected but still I am facing same issue

Azaz0723 avatar Sep 30 '22 06:09 Azaz0723

None of this working for me. Xcode 14 and react-native 0.68

akashkrshukla avatar Nov 04 '22 02:11 akashkrshukla

For me, use_flipper!({ "Flipper-DoubleConversion" => "1.1.7" }) in Podfile fixed this.

In my case: use_flipper!({'Flipper' => '0.140.0', "Flipper-DoubleConversion" => "1.1.7"})

Okay so this worked on my end with RN 0.67.5 but it is a bit of a hack IMO. Does anyone know what the underlying cause is for this? I suspect it could be related to past RN upgrades done incorrectly as our app came from 0.59 to 0.63 to 0.67.

brianangulo avatar Dec 01 '22 20:12 brianangulo

At this point even discussing Flipper implies you're two major versions behind here and failing steadily further back as it doesn't work with use_frameworks. I don't see Flipper prioritized for fixing yet (fixing new architecture + use_frameworks is a higher priority for react-native crew) so I'd say it's probably time to device a different troubleshooting strategy, disable flipper and get on current versions. But that's me....

mikehardy avatar Dec 01 '22 21:12 mikehardy

At this point even discussing Flipper implies you're two major versions behind here and failing steadily further back as it doesn't work with use_frameworks. I don't see Flipper prioritized for fixing yet (fixing new architecture + use_frameworks is a higher priority for react-native crew) so I'd say it's probably time to device a different troubleshooting strategy, disable flipper and get on current versions. But that's me....

Thanks @mikehardy, I see your point. We are trying to catch up as fast as we can. Regarding this issue, I've been digging into it a bit more and although I don't have full clarity just yet I did find that selecting Yes for both Dead Code Stripping and Don't Dead-Strip Inits and Terms also works in my case (similarly to what others have posted in this issue) without the need to explicitly select a Flipper-DoubleConversion version.

Screen Shot 2022-12-01 at 3 44 22 PM

brianangulo avatar Dec 01 '22 21:12 brianangulo

I was having this problem on an m1 mac, so the symbols are for arm64, but I think the solution might be the same. After spending a few hours trying out different solutions to this, I solved this by removing /opt/homebrew/opt/coreutils/libexec/gnubin/ from my path. That's right, I had gnu coreutils set as my default for commands like cp, which react-native's build scripts use. The net result was that extra files were being copied, due to subtle differences in how directories are copied between the gnu and the builtin cp.

kamatsuoka avatar Dec 13 '22 02:12 kamatsuoka

I was having this problem on an m1 mac, so the symbols are for arm64, but I think the solution might be the same. After spending a few hours trying out different solutions to this, I solved this by removing /opt/homebrew/opt/coreutils/libexec/gnubin/ from my path. That's right, I had gnu coreutils set as my default for commands like cp, which react-native's build scripts use. The net result was that extra files were being copied, due to subtle differences in how directories are copied between the gnu and the builtin cp.

This saved my life, thanks a lot!

Quickfix

For those who encounter the same problem, this is a hack to exclude the gnu coreutils from your $PATH without actually removing it from your ~/.bash_profile.

Option 1: wrapping npx calls into a wrapper for now (such that react-native and pod-install could both reuse the same wrapper)

# npx-wrapper
#!/usr/bin/env bash
PATH="$(echo "$PATH" | tr ':' '\n' | grep -v 'coreutils/libexec/gnubin' | paste -sd: -)" npx "$@"

Option 2: just remember to exclude it before calling any ios related commands

# *before* calling any ios related commands
export PATH="$(echo "$PATH" | tr ':' '\n' | grep -v 'coreutils/libexec/gnubin' | paste -sd: -)"
# otherwise you might have to somehow delete the ~/Library/Developer/Xcode/DerivedData and/or ios/build and start over (the goal is to clean up the object files and the statically linked libraries)

As it appears to work if we exclude the gnu coreutils, one possible fix for the problem would be using POSIX-compliant options for those commands in the build scripts.

leoslf avatar Jan 02 '23 22:01 leoslf

For me, use_flipper!({ "Flipper-DoubleConversion" => "1.1.7" }) in Podfile fixed this.

just put it anywhere?

NoodleOfDeath avatar Apr 04 '23 20:04 NoodleOfDeath

I have this in my pod already

use_flipper!({ 'Flipper' => '0.125.0' }, configurations: ['Debug'])

and adding another line like this:

use_flipper!({ 'Flipper' => '0.125.0' }, configurations: ['Debug'])
use_flipper!({ "Flipper-DoubleConversion" => "1.1.7" })

breaks the pod installation process:

[!] CocoaPods could not find compatible versions for pod "Flipper-DoubleConversion":
  In Podfile:
    Flipper-DoubleConversion (= 1.1.7)

    Flipper-DoubleConversion (= 3.2.0)

None of your spec sources contain a spec satisfying the dependencies: `Flipper-DoubleConversion (= 3.2.0), Flipper-DoubleConversion (= 1.1.7)`.

You have either:
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.

[!] There are duplicate dependencies on `Flipper-DoubleConversion` in `Podfile`:

- Flipper-DoubleConversion (= 3.2.0)
- Flipper-DoubleConversion (= 1.1.7)

Is there a way to merge these two use_flipper! instructions?

alexeystrakh avatar Apr 05 '23 02:04 alexeystrakh

I have this in my pod already

use_flipper!({ 'Flipper' => '0.125.0' }, configurations: ['Debug'])

and adding another line like this:

use_flipper!({ 'Flipper' => '0.125.0' }, configurations: ['Debug'])
use_flipper!({ "Flipper-DoubleConversion" => "1.1.7" })

breaks the pod installation process:

[!] CocoaPods could not find compatible versions for pod "Flipper-DoubleConversion":
  In Podfile:
    Flipper-DoubleConversion (= 1.1.7)

    Flipper-DoubleConversion (= 3.2.0)

None of your spec sources contain a spec satisfying the dependencies: `Flipper-DoubleConversion (= 3.2.0), Flipper-DoubleConversion (= 1.1.7)`.

You have either:
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.

[!] There are duplicate dependencies on `Flipper-DoubleConversion` in `Podfile`:

- Flipper-DoubleConversion (= 3.2.0)
- Flipper-DoubleConversion (= 1.1.7)

Is there a way to merge these two use_flipper! instructions?

yes, I believe you can use use_flipper!({ 'Flipper' => '0.125.0' , "Flipper-DoubleConversion" => "1.1.7"}, configurations: ['Debug']) to merge them

nikolasvasconcelos avatar Apr 05 '23 22:04 nikolasvasconcelos

Best solution here is to delete React Native and with it; your entire existing app. Switch to a competent framework, such as:

These frameworks are comprehensive, maintained by competent developers, and future proof - which is far more than I can say for the mess in which React Native has turned itself into, it's:

Consistent usage on deprecated frameworks such as UIKit (Apple has long-since shifted their focus onwards to SwiftUI)

Horrendously written code, an actual example: https://github.com/facebook/react-native/blob/a6690bfb7b43120608ef17d1e7f08c9eb111e98f/packages/react-native/React/Fabric/RCTSurfacePresenter.mm#L186-L191

Duplicate symbols as you find in this issue ticket today.

Autogenerated garbage C++ code they call ✨ "Native" ✨ "turbo modules" and "new architecture" which are just marketing buzzwords they throw around for some pretty horrendous looking C++ code because Meta/Facebook has decided they no longer would like to maintain native code, for new autogenerated code that is not maintainable by humans and is subject to all sorts of delightful compiler errors (..."window" is not available in this iOS version...) that you will have no control of fixing yourself (the changes you need to make are located in node_modules), and anything you attempt to change within the autogenerated junk at build time will be undone between each and every re-build.

Senseless hours wasting your time trying to fix all the things Meta/Facebook (will not/cannot) fix.

Concurrent queues with incorrectly set Quality of Service execution priorities, as the Facebook developers have decided "they know better" and will actually just ignore the Apple documentation instead.

The metro bundler which will spontaneously choose whether or not (if the sun is in perfect alignment with the moon) if it will actually decide to bundle your app that day.

Assets magically disappearing in production builds.

To have a barely functioning app, built on a foundation of deprecated UI frameworks which will inevitably become obsolete in an upcoming flagship release, rendering all your efforts here as useless when either the device or the App Store rejects your app.

Hic sunt dracones - This is not the development experience you are looking for.

DO_NOT_USE_DEPRECATED - Meta Platforms, Inc.

I don't know what happened here, perhaps JavaScript has gotten out of hand; being treated as some sort of Python equivalent (it's not), but for the sake of developer sanity and everyone involved, it's time to let this project go. I hope Meta/Facebook can take this as a learning opportunity moving forward.

A developer who has resorted to every last measure to breathe fresh life into this dying project. Including forking and maintaining a custom react native build, and rewriting it from the ground up for SwiftUI, with a patience that continues to grow warily thin.

furby-tm avatar Apr 08 '23 23:04 furby-tm

Best solution here is to delete React Native and with it; your entire existing app.

This issue isn't your personal soapbox.

arancauchi avatar May 12 '23 02:05 arancauchi

I am facing the same issues with react-native version 0.71.3

Update: If you're encountering a similar issue of duplicate symbols .... I discovered that my problem stemmed from having both rn-fetch-blob and react-native-blob-util installed. These packages essentially serve the same purpose, so installing both is unnecessary. Opt for just one of them. I recommend using react-native-blob-util.

MuhammadAbdullah54321 avatar Sep 20 '23 19:09 MuhammadAbdullah54321

Experienced the same issue when adding Expo to an existing React Native project. RN version: 0.72.4

The solution proposed by @wjaykim worked like a charm!

jhjdev avatar Nov 02 '23 01:11 jhjdev