react-native: duplicate symbol 'folly::exception_wrapper::from_exception_ptr(std::exception_ptr&&)' React Native 0.66 with hermes enabled

Description

I was on 0.65.1 (with Hermes enabled) and tried to perform an upgrade to 0.66 today and after performing all necessary changes as mentioned in upgrade helper, I finally performed a clean install and tried to run the app and now it is not working anymore, It is throwing duplicate symbol errors related to flipper between RCT-folly and Flipper-folly. Also, I faced a similar issue when I upgraded to 0.65.1 but at that time this fix worked: https://github.com/react-native-community/releases/issues/235#issuecomment-863308604 I tried this here but doesn’t seems working Here is the error from Xcode:

duplicate symbol 'folly::detail::str_to_bool(folly::Range<char const*>*)' in:
    /Users/umangloriya/Library/Developer/Xcode/DerivedData/App-gafjkayoxqdgqvdjhytxqqiubosa/Build/Products/Debug-iphonesimulator/Flipper-Folly/libFlipper-Folly.a(Conv.o)
    /Users/umangloriya/Library/Developer/Xcode/DerivedData/App-gafjkayoxqdgqvdjhytxqqiubosa/Build/Products/Debug-iphonesimulator/RCT-Folly/libRCT-Folly.a(Conv.o)
duplicate symbol 'folly::makeConversionError(folly::ConversionCode, folly::Range<char const*>)' in:
    /Users/umangloriya/Library/Developer/Xcode/DerivedData/App-gafjkayoxqdgqvdjhytxqqiubosa/Build/Products/Debug-iphonesimulator/Flipper-Folly/libFlipper-Folly.a(Conv.o)
    /Users/umangloriya/Library/Developer/Xcode/DerivedData/App-gafjkayoxqdgqvdjhytxqqiubosa/Build/Products/Debug-iphonesimulator/RCT-Folly/libRCT-Folly.a(Conv.o)
duplicate symbol 'folly::exception_wrapper::from_exception_ptr(std::exception_ptr&&)' in:
    /Users/umangloriya/Library/Developer/Xcode/DerivedData/App-gafjkayoxqdgqvdjhytxqqiubosa/Build/Products/Debug-iphonesimulator/Flipper-Folly/libFlipper-Folly.a(ExceptionWrapper.o)
    /Users/umangloriya/Library/Developer/Xcode/DerivedData/App-gafjkayoxqdgqvdjhytxqqiubosa/Build/Products/Debug-iphonesimulator/RCT-Folly/libRCT-Folly.a(ExceptionWrapper.o)
duplicate symbol 'folly::exception_wrapper::from_exception_ptr(std::exception_ptr const&)' in:
    /Users/umangloriya/Library/Developer/Xcode/DerivedData/App-gafjkayoxqdgqvdjhytxqqiubosa/Build/Products/Debug-iphonesimulator/Flipper-Folly/libFlipper-Folly.a(ExceptionWrapper.o)
    /Users/umangloriya/Library/Developer/Xcode/DerivedData/App-gafjkayoxqdgqvdjhytxqqiubosa/Build/Products/Debug-iphonesimulator/RCT-Folly/libRCT-Folly.a(ExceptionWrapper.o)
duplicate symbol 'folly::exception_wrapper::onNoExceptionError(char const*)' in:
    /Users/umangloriya/Library/Developer/Xcode/DerivedData/App-gafjkayoxqdgqvdjhytxqqiubosa/Build/Products/Debug-iphonesimulator/Flipper-Folly/libFlipper-Folly.a(ExceptionWrapper.o)
    /Users/umangloriya/Library/Developer/Xcode/DerivedData/App-gafjkayoxqdgqvdjhytxqqiubosa/Build/Products/Debug-iphonesimulator/RCT-Folly/libRCT-Folly.a(ExceptionWrapper.o)
duplicate symbol 'folly::exceptionStr(folly::exception_wrapper const&)' in:
    /Users/umangloriya/Library/Developer/Xcode/DerivedData/App-gafjkayoxqdgqvdjhytxqqiubosa/Build/Products/Debug-iphonesimulator/Flipper-Folly/libFlipper-Folly.a(ExceptionWrapper.o)
    /Users/umangloriya/Library/Developer/Xcode/DerivedData/App-gafjkayoxqdgqvdjhytxqqiubosa/Build/Products/Debug-iphonesimulator/RCT-Folly/libRCT-Folly.a(ExceptionWrapper.o)
duplicate symbol 'folly::exception_wrapper::uninit_' in:
    /Users/umangloriya/Library/Developer/Xcode/DerivedData/App-gafjkayoxqdgqvdjhytxqqiubosa/Build/Products/Debug-iphonesimulator/Flipper-Folly/libFlipper-Folly.a(ExceptionWrapper.o)
    /Users/umangloriya/Library/Developer/Xcode/DerivedData/App-gafjkayoxqdgqvdjhytxqqiubosa/Build/Products/Debug-iphonesimulator/RCT-Folly/libRCT-Folly.a(ExceptionWrapper.o)
duplicate symbol 'folly::exception_wrapper::ExceptionPtr::ops_' in:
    /Users/umangloriya/Library/Developer/Xcode/DerivedData/App-gafjkayoxqdgqvdjhytxqqiubosa/Build/Products/Debug-iphonesimulator/Flipper-Folly/libFlipper-Folly.a(ExceptionWrapper.o)
    /Users/umangloriya/Library/Developer/Xcode/DerivedData/App-gafjkayoxqdgqvdjhytxqqiubosa/Build/Products/Debug-iphonesimulator/RCT-Folly/libRCT-Folly.a(ExceptionWrapper.o)
duplicate symbol 'folly::exception_wrapper::SharedPtr::ops_' in:
    /Users/umangloriya/Library/Developer/Xcode/DerivedData/App-gafjkayoxqdgqvdjhytxqqiubosa/Build/Products/Debug-iphonesimulator/Flipper-Folly/libFlipper-Folly.a(ExceptionWrapper.o)
    /Users/umangloriya/Library/Developer/Xcode/DerivedData/App-gafjkayoxqdgqvdjhytxqqiubosa/Build/Products/Debug-iphonesimulator/RCT-Folly/libRCT-Folly.a(ExceptionWrapper.o)
ld: 9 duplicate symbols for architecture arm64

React Native version:

Run react-native info in your terminal and copy the results here.

System:
    OS: macOS 11.6
    CPU: (8) arm64 Apple M1
    Memory: 157.19 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.0.0 - /opt/homebrew/bin/node
    Yarn: 1.22.11 - /opt/homebrew/bin/yarn
    npm: 6.14.13 - /opt/homebrew/bin/npm
    Watchman: 4.9.0 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.2 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 15.0, DriverKit 20.4, macOS 11.3, tvOS 15.0, watchOS 8.0
    Android SDK:
      API Levels: 23, 29, 30
      Build Tools: 29.0.2, 30.0.0, 30.0.2, 30.0.3
      System Images: android-30 | Google APIs ARM 64 v8a, android-S | Google APIs ARM 64 v8a
      Android NDK: Not Found
  IDEs:
    Android Studio: 2020.3 AI-203.7717.56.2031.7678000
    Xcode: 13.0/13A233 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_292 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.66.0 => 0.66.0 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. Upgrade to 0.66.0 with hermes enable for iOS 2.Build/Run the project

Expected Results

It should build/run just fine without throwing error

Snack, code example, screenshot, or link to a repository:

Here is my podfile

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

# Override Firebase SDK Version

platform :ios, '13.0'
install! 'cocoapods', :deterministic_uuids => false

target 'NotificationServiceExt' do
  pod 'Firebase/Messaging'
end

target 'App' do
  # Pods for App
  pod 'libwebp', :modular_headers => true
  # Add the pod for Firebase Cloud Messaging
  pod 'Firebase/Messaging'
  config = use_native_modules!
  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => true
  )
  # Enables Flipper.
  use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 8
  • Comments: 21 (3 by maintainers)

Most upvoted comments

We ended up recreating the ios project using a fresh react-native init, then readded everything to the iOS project (we also wrote a script like the one linked previously to automate this in case we need it: https://github.com/facebook/react-native/issues/32333#issuecomment-939939970) and it is set as YES by default: image

I confirm this is also not present in the pbxproj file anymore.

This is a change that occured in RN 0.62.0, this commit in particular : https://github.com/facebook/react-native/commit/e3218a0d965f6ec69cc31cd7c536678e165b96c1#diff-5e5f05dcdf7a14aea292c3172649e6a220923662fdb41d409997c37da721d27eL505, so I’m not sure it would cause debugging issues if this was a change related to Flipper. Even if I find it weird to activate this setting in a debug configuration, but whatever. XCode and pbxproj are a mess.

Switching it to NO on a new project bring back the problem with 9 duplicate symbols for architecture x86_64. Just wanted to provide context as to why only some people encoutered this issue, and why it works on a new project.

While this issue is addressed, you can disable flipper:

# use_flipper!({ ...

in your Podfile and reinstall Pods

We ended up recreating the ios project using a fresh react-native init, then readded everything to the iOS project (we also wrote a script like the one linked previously to automate this in case we need it: #32333 (comment)) and it is set as YES by default: image

I confirm this is also not present in the pbxproj file anymore.

This is a change that occured in RN 0.62.0, this commit in particular : e3218a0#diff-5e5f05dcdf7a14aea292c3172649e6a220923662fdb41d409997c37da721d27eL505, so I’m not sure it would cause debugging issues if this was a change related to Flipper. Even if I find it weird to activate this setting in a debug configuration, but whatever. XCode and pbxproj are a mess.

Switching it to NO on a new project bring back the problem with 9 duplicate symbols for architecture x86_64. Just wanted to provide context as to why only some people encoutered this issue, and why it works on a new project.

This is exactly it! Great experiments to find out the reasons behind this weird behaviour that wasted so much of my time to debug it.

@umang-simform enabling dead code deletions would cause debugging issues IMO

@escobar5 @samih7 The way I solved the issue is by modifying project.pbxproj file. You can find detailed info here: https://stackoverflow.com/a/69555877/7440820

@umang-simform Could you elaborate?

I got the same error even in v0.65

For 0.65 try this fix: react-native-community/releases#235 (comment) It worked for me. but it is not working for 0.66

Same here. Error: ld: 9 duplicate symbols for architecture arm64

We ended up recreating the ios project using a fresh react-native init, then readded everything to the iOS project (we also wrote a script like the one linked previously to automate this in case we need it: #32333 (comment)) and it is set as YES by default: image

I confirm this is also not present in the pbxproj file anymore.

This is a change that occured in RN 0.62.0, this commit in particular : e3218a0#diff-5e5f05dcdf7a14aea292c3172649e6a220923662fdb41d409997c37da721d27eL505, so I’m not sure it would cause debugging issues if this was a change related to Flipper. Even if I find it weird to activate this setting in a debug configuration, but whatever. XCode and pbxproj are a mess.

Switching it to NO on a new project bring back the problem with 9 duplicate symbols for architecture x86_64. Just wanted to provide context as to why only some people encoutered this issue, and why it works on a new project.

You are a legend, thank you!

Removing DEAD_CODE_STRIPPING = NO; makes the app crash in debug for me.

Mystery solved! Great analysis

I got the same error even in v0.65