无法编译 React Native iOS 应用以在物理设备上运行,React Native Firebase 出现问题

ale*_*ngn 12 xcode ios firebase react-native react-native-firebase

最近出于某种原因,我无法从 Xcode 甚至从命令行在物理设备上运行我的 React Native 应用程序。我收到以下错误:

duplicate symbol '_md5_block_data_order' in:
    /XXX/Library/Developer/Xcode/DerivedData/XXXX-bdrylwsxpcqgzvgkcljteyttcdmr/Build/Products/Debug-iphoneos/BoringSSL-GRPC/libBoringSSL-GRPC.a(md5.o)
    /XXX/project/ios/Pods/OpenSSL-Universal/ios/lib/libcrypto.a(md5_dgst.o)
ld: 1 duplicate symbol for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

但是它在模拟器上运行良好。我可以毫无问题地将应用程序上传到 AppStoreConnect。

据我了解,2 个库中似乎存在相同的符号。不知道为什么,很可能是移动应用程序依赖项之一。

在安装的 Pod 列表中,我同时拥有BoringSSL-GRPC (0.0.3)OpenSSL-Universal (1.0.2.19)

Firebase 使用 BoringSSL,Flipper 使用 OpenSSL。

这是我使用的第三方依赖项列表:

  pod 'Firebase/Core', '~> 6.3.0'

  pod 'Firebase/Messaging', '~> 6.3.0'

  pod 'Firebase/Firestore', '~> 6.3.0'

  pod 'Firebase/Auth', '~> 6.3.0'

  pod 'TrustKit'

  pod 'Stripe', '16.0.0'

  pod 'Amplitude-iOS', '~> 4.5'

  pod 'Intercom', '~> 5.5.1'

  flipper_pods()

Run Code Online (Sandbox Code Playgroud)

当我一起删除 Firebase 时,它​​工作正常,我可以在设备上运行我的应用程序。但我需要 Firebase...

知道如何解决这个问题吗?

谢谢!

Mik*_*rdy 10

这是其他人也注意到的问题https://github.com/invertase/react-native-firebase/issues/3384

大多数人看到的症状如下:

Pods/OpenSSL-Universal/ios/lib/libcrypto.a(bio_lib.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
Run Code Online (Sandbox Code Playgroud)

此处记录了一个上游问题https://github.com/facebook/flipper/issues/485,该问题在很明显这将是一个比预期更大的问题之前已关闭。

我测试了一种变通方法,该变通方法目前不是最佳但功能正常,直到在传递依赖项中可以使用带有 bitcode 的 OpenSSL 库 - 变通方法是

  • 禁用用于开发的位码(即存在翻转器的地方)
  • 确保你在任何地方都打开了死代码剥离
  • 为发布模式启用位码

根据我的经验,这适用于本地设备上的调试版本(之前失败),并且在发布模式下的 TestFlight 版本有效

希望这可以帮助!

  • 你好呀。还有其他问题的解决方法以及安装指南,指导您制作虚拟 Swift 桥接头*并将其保留在适当的位置*。这也是推荐的https://fbflipper.com/docs/troubleshooting#build-errors-in-react-native - 请注意,我在react-native-firebase问题跟踪器中讨论了这个问题,问题最终解决了这些错误,并已修复 - 所以它有点hacky但它​​确实有效。https://github.com/invertase/react-native-firebase/issues/3384#issuecomment-626345098 (2认同)

Len*_*Bru -3

清理项目然后运行,为模拟器编译库并为设备创建重复项