重复符号'folly::exception_wrapper::from_exception_ptr(std::exception_ptr&&)' React Native 0.66启用Hermes

22
将英文翻译成中文:
在更新我的应用程序到react-native v0.66.0之后,如果启用了hermes,我会不断收到此错误。我尝试删除DerivedData文件夹、podfile podfile.lock等,但没有帮助。
终端输出:
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

我想使用Flipper调试我的应用程序,并启用了Hermes,谢谢。
编辑:我可以从Xcode构建项目。

1
是的,在启用Hermes后升级后仍然遇到相同的错误。 - Umang Loriya
我在升级到0.66版之后也遇到了这个问题。 对我来说,唯一的两个解决方案是禁用hermes,或禁用flipper(注释掉use_flipper!())。 - YaNuSH
1
@cuongtd 如果你找到了解决方案,请告诉我。 我最终降级回到0.65.1。 - YaNuSH
我注意到他们将Hermes从0.8.1升级到了0.9,所以如果有办法只降级Hermes,那么这个问题可能会得到解决,但我不知道如何做到这一点。 - YaNuSH
1
谢谢@cuongtd!那真的有效。 - YaNuSH
显示剩余5条评论
1个回答

36

现在我成功地运行了项目,通过删除某些内容。

DEAD_CODE_STRIPPING = NO;

在 project.pbxproj 文件中

或者在 Xcode 的 Build Settings 选项卡中启用调试模式下的死代码剥离

输入图像描述


这个问题已经解决了。但是现在我的应用程序在启动模拟器时崩溃了。 - lucas emanuel himelfarb
1
值得注意的是,在启用 react-native 上的 flipper 时,对于 macCatalyst 构建来说这是 绝对 必需的。在 react-native 0.68.0.rc-2 上,似乎不需要在 ios 上构建 flipper(至少在 0.67 上也是如此),但是对于 macCatalyst,一定要这样做。https://github.com/facebook/flipper/issues/3117 - Mike Hardy

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接