22

After updating my app to react-native v0.66.0, I keep getting this error if hermes is enabled. I tried to delete DerivedData folder, podfile podfile.lock... but nothing helped

terminal output

duplicate symbol 'folly::exception_wrapper::from_exception_ptr(std::exception_ptr&&)' in:
    /Users/cuongtd/Library/Developer/Xcode/DerivedData/MyApp-ekbbcdnefrapxuertuowclstsjop/Build/Products/Debug-iphonesimulator/Flipper-Folly/libFlipper-Folly.a(ExceptionWrapper.o)
    /Users/cuongtd/Library/Developer/Xcode/DerivedData/MyApp-ekbbcdnefrapxuertuowclstsjop/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/cuongtd/Library/Developer/Xcode/DerivedData/MyApp-ekbbcdnefrapxuertuowclstsjop/Build/Products/Debug-iphonesimulator/Flipper-Folly/libFlipper-Folly.a(ExceptionWrapper.o)
    /Users/cuongtd/Library/Developer/Xcode/DerivedData/MyApp-ekbbcdnefrapxuertuowclstsjop/Build/Products/Debug-iphonesimulator/RCT-Folly/libRCT-Folly.a(ExceptionWrapper.o)
duplicate symbol 'folly::exception_wrapper::onNoExceptionError(char const*)' in:
    /Users/cuongtd/Library/Developer/Xcode/DerivedData/MyApp-ekbbcdnefrapxuertuowclstsjop/Build/Products/Debug-iphonesimulator/Flipper-Folly/libFlipper-Folly.a(ExceptionWrapper.o)
    /Users/cuongtd/Library/Developer/Xcode/DerivedData/MyApp-ekbbcdnefrapxuertuowclstsjop/Build/Products/Debug-iphonesimulator/RCT-Folly/libRCT-Folly.a(ExceptionWrapper.o)
duplicate symbol 'folly::exceptionStr(folly::exception_wrapper const&)' in:
    /Users/cuongtd/Library/Developer/Xcode/DerivedData/MyApp-ekbbcdnefrapxuertuowclstsjop/Build/Products/Debug-iphonesimulator/Flipper-Folly/libFlipper-Folly.a(ExceptionWrapper.o)
    /Users/cuongtd/Library/Developer/Xcode/DerivedData/MyApp-ekbbcdnefrapxuertuowclstsjop/Build/Products/Debug-iphonesimulator/RCT-Folly/libRCT-Folly.a(ExceptionWrapper.o)
duplicate symbol 'folly::exception_wrapper::uninit_' in:
    /Users/cuongtd/Library/Developer/Xcode/DerivedData/MyApp-ekbbcdnefrapxuertuowclstsjop/Build/Products/Debug-iphonesimulator/Flipper-Folly/libFlipper-Folly.a(ExceptionWrapper.o)
    /Users/cuongtd/Library/Developer/Xcode/DerivedData/MyApp-ekbbcdnefrapxuertuowclstsjop/Build/Products/Debug-iphonesimulator/RCT-Folly/libRCT-Folly.a(ExceptionWrapper.o)
duplicate symbol 'folly::exception_wrapper::ExceptionPtr::ops_' in:
    /Users/cuongtd/Library/Developer/Xcode/DerivedData/MyApp-ekbbcdnefrapxuertuowclstsjop/Build/Products/Debug-iphonesimulator/Flipper-Folly/libFlipper-Folly.a(ExceptionWrapper.o)
    /Users/cuongtd/Library/Developer/Xcode/DerivedData/MyApp-ekbbcdnefrapxuertuowclstsjop/Build/Products/Debug-iphonesimulator/RCT-Folly/libRCT-Folly.a(ExceptionWrapper.o)
duplicate symbol 'folly::exception_wrapper::SharedPtr::ops_' in:
    /Users/cuongtd/Library/Developer/Xcode/DerivedData/MyApp-ekbbcdnefrapxuertuowclstsjop/Build/Products/Debug-iphonesimulator/Flipper-Folly/libFlipper-Folly.a(ExceptionWrapper.o)
    /Users/cuongtd/Library/Developer/Xcode/DerivedData/MyApp-ekbbcdnefrapxuertuowclstsjop/Build/Products/Debug-iphonesimulator/RCT-Folly/libRCT-Folly.a(ExceptionWrapper.o)
ld: 7 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

ios/podfile

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

target 'MyApp' do
  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
  )

  # Pods for MyApp
  pod 'Firebase/Analytics'
  pod 'AFNetworking', '~> 4.0', :source => 'https://github.com/ElfSundae/CocoaPods-Specs.git'

  use_flipper!()
  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)

    installer.aggregate_targets.each do |aggregate_target| 
      aggregate_target.user_project.native_targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['LIBRARY_SEARCH_PATHS'] = ['$(SDKROOT)/usr/lib/swift', '$(inherited)']
        end
      end
      aggregate_target.user_project.save
    end

    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
       end
    end
    `sed -i -e  $'s/__IPHONE_10_0/__IPHONE_12_0/' #{installer.sandbox.root}/RCT-Folly/folly/portability/Time.h`
  end
end

I want to use flipper to debug my app and hermes is enabled, thank all.

Edit: I can build the project from Xcode

cuongtd
  • 2,862
  • 3
  • 19
  • 37
  • Can you try changing your podfile to use `use_flipper!({ "Flipper-DoubleConversion" => "1.1.7" })`? I had a similar issue today and fixed it through that. See https://github.com/react-native-community/releases/issues/235#issuecomment-863308604 – Jeroen Vannevel Oct 04 '21 at 16:18
  • thank @JeroenVannevel. I tried it, it worked only when hermes was disabled – cuongtd Oct 04 '21 at 16:36
  • 1
    Yeah, Getting the same error after upgrade with hermes enabled. – Umang Loriya Oct 05 '21 at 03:48
  • I also had this problem after upgrading to 0.66. The only two solutions for me were to either disable hermes, or disable flipper (comment out use_flipper!()) – YaNuSH Oct 08 '21 at 07:35
  • @YaNuSH yeah I know, the point that I want to enable them both – cuongtd Oct 08 '21 at 07:43
  • 1
    @cuongtd let mw know if you ever find a solution. I ended up downgrading back to 0.65.1 – YaNuSH Oct 08 '21 at 07:47
  • I noticed they upgraded hermes from 0.8.1 to 0.9, so maybe if there is a way to downgrade only hermes it would solve the issue, but I don't know how to do that – YaNuSH Oct 08 '21 at 07:52
  • @YaNuSH I don't know either, so confused about ios things. I see many people raised this issue in react-native repo but no one responded yet. – cuongtd Oct 08 '21 at 07:59
  • @YaNuSH I can run project now, check it from your end – cuongtd Oct 14 '21 at 04:26
  • 1
    Thanks @cuongtd! that actually worked – YaNuSH Oct 14 '21 at 07:03

1 Answers1

35

I can run project successfully now by removing

DEAD_CODE_STRIPPING = NO;

in project.pbxproj

or go to Build Settings tab in Xcode then enable Dead Code Stripping for Debug mode

enter image description here

cuongtd
  • 2,862
  • 3
  • 19
  • 37
  • This solve it. But now my app crashed when started simulator – lucas emanuel himelfarb Jan 18 '22 at 18:30
  • 1
    Worth noting that for some reason with flipper enabled on react-native this is *definitely* required for macCatalyst builds. It did not seem to be needed for flipper builds on ios for react-native 0.68.0.rc-2 at least (nor on 0.67) but for macCatalyst, definitely. https://github.com/facebook/flipper/issues/3117 – Mike Hardy Mar 15 '22 at 17:14