无法使用Firebase ML Kit视觉文本检测器编译iOS React Native应用

Fra*_* Li 5 ios firebase react-native firebase-mlkit

我正在使用React Native构建一个应用程序,该应用程序已“弹出”到其自己的iOS本地应用程序项目中。我对使用新的Firebase ML Kit视觉文本检测器以使用设备上模型识别图像中的文本感兴趣,并且我愿意为此编写自己的NativeModule包装器(因为它很新,所以我看不到项目中的任何现有包装器(例如react-native-firebase)。

因此,我使用Cocoapods引入了Firebase依赖项,但是当我尝试编译新的工作区时,出现以下链接器错误:

duplicate symbol __ZN3fLB28FLAGS_nosymbolize_stacktraceE in:
    /Users/francisli/Projects/clients/app/apptag-app/ios/Pods/GoogleMobileVision/TextDetector/Frameworks/TextDetector.framework/TextDetector(examine_stack_b03c119c7358b452600b1afd20ca186c.o)
    /Users/francisli/Library/Developer/Xcode/DerivedData/AppTag-arpnqvohzbwieueghdomemjvqvxt/Build/Products/Debug-iphonesimulator/libReact.a(utilities.o)
duplicate symbol __ZN3fLB26FLAGS_symbolize_stacktraceE in:
    /Users/francisli/Projects/clients/app/apptag-app/ios/Pods/GoogleMobileVision/TextDetector/Frameworks/TextDetector.framework/TextDetector(examine_stack_b03c119c7358b452600b1afd20ca186c.o)
    /Users/francisli/Library/Developer/Xcode/DerivedData/AppTag-arpnqvohzbwieueghdomemjvqvxt/Build/Products/Debug-iphonesimulator/libReact.a(utilities.o)
duplicate symbol __ZN3fLI9FLAGS_novE in:
    /Users/francisli/Projects/clients/app/apptag-app/ios/Pods/GoogleMobileVision/TextDetector/Frameworks/TextDetector.framework/TextDetector(vlog_is_on_ec23571a5409c45b7e2ca681c18af4cb.o)
    /Users/francisli/Library/Developer/Xcode/DerivedData/AppTag-arpnqvohzbwieueghdomemjvqvxt/Build/Products/Debug-iphonesimulator/libReact.a(vlog_is_on.o)
duplicate symbol __ZN3fLI7FLAGS_vE in:
    /Users/francisli/Projects/clients/app/apptag-app/ios/Pods/GoogleMobileVision/TextDetector/Frameworks/TextDetector.framework/TextDetector(vlog_is_on_ec23571a5409c45b7e2ca681c18af4cb.o)
    /Users/francisli/Library/Developer/Xcode/DerivedData/AppTag-arpnqvohzbwieueghdomemjvqvxt/Build/Products/Debug-iphonesimulator/libReact.a(vlog_is_on.o)
duplicate symbol __ZN3fLS13FLAGS_vmoduleE in:
    /Users/francisli/Projects/clients/app/apptag-app/ios/Pods/GoogleMobileVision/TextDetector/Frameworks/TextDetector.framework/TextDetector(vlog_is_on_ec23571a5409c45b7e2ca681c18af4cb.o)
    /Users/francisli/Library/Developer/Xcode/DerivedData/AppTag-arpnqvohzbwieueghdomemjvqvxt/Build/Products/Debug-iphonesimulator/libReact.a(vlog_is_on.o)
duplicate symbol __ZN3fLB18FLAGS_nolog_prefixE in:
    /Users/francisli/Projects/clients/app/apptag-app/ios/Pods/GoogleMobileVision/TextDetector/Frameworks/TextDetector.framework/TextDetector(logging_2072041cb58f7b92d4eb8dae33e75a0d.o)
    /Users/francisli/Library/Developer/Xcode/DerivedData/AppTag-arpnqvohzbwieueghdomemjvqvxt/Build/Products/Debug-iphonesimulator/libReact.a(logging.o)
duplicate symbol __ZN3fLB16FLAGS_log_prefixE in:
    /Users/francisli/Projects/clients/app/apptag-app/ios/Pods/GoogleMobileVision/TextDetector/Frameworks/TextDetector.framework/TextDetector(logging_2072041cb58f7b92d4eb8dae33e75a0d.o)
    /Users/francisli/Library/Developer/Xcode/DerivedData/AppTag-arpnqvohzbwieueghdomemjvqvxt/Build/Products/Debug-iphonesimulator/libReact.a(logging.o)
ld: 7 duplicate symbols for architecture x86_64
Run Code Online (Sandbox Code Playgroud)

根据我对React Native项目中其他重复符号错误情况的了解,这通常是由于除了手动将React项目链接到主应用程序项目之外,还包括依赖于React的Pod弹出后,以及其他使用react-native link)链接的库。但是,事实并非如此-我要通过Podfile插入的唯一库与Firebase相关,所以我不确定冲突是如何发生的。

任何人(也许是Firebase团队正在研究适用于iOS的新ML工具包)的任何见解?注意,我什至还没有编写任何引用框架的代码,我只是想让工作区配置得以编译。这是Podfile供参考:

# Uncomment the next line to define a global platform for your project
platform :ios, '11.3'

target 'App' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for App
  pod 'Firebase/Core'
  pod 'Firebase/MLVision'
  pod 'Firebase/MLVisionTextModel'

  target 'AppTests' do
    inherit! :search_paths
    # Pods for testing
  end

end
Run Code Online (Sandbox Code Playgroud)

这是主应用程序项目中所有链接库项目的屏幕截图:

先前链接的项目依赖项

Rya*_*Lee 4

我在将 ML kit 应用于 RN 项目时遇到了同样的问题。这是解决方案:

选择“主要目标”>“构建设置”>“死剥离代码”=“是”

希望它能帮助你度过难关。