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

标签 ios firebase react-native firebase-mlkit

我正在使用 React Native 构建一个应用程序,我已经将它“弹出”到它自己的 iOS native 应用程序项目中。我对使用新的 Firebase ML Kit Vision Text Detector 通过 on-device 模型识别图像中的文本很感兴趣,并且我愿意为它编写自己的 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

从我读到的 React Native 项目中重复符号错误的其他案例来看,这通常是由于包含依赖于 React 的 pod 以及手动将 React 项目链接到主应用程序项目(因为它最初是在弹出后设置的,以及使用 react-native link 链接的其他库)。然而,这里的情况并非如此——我通过 podfile 引入的唯一库是 Firebase 相关的,所以我不确定冲突是如何发生的。

来自任何人的任何见解 - 也许来自致力于新的 iOS 机器学习套件的 Firebase 团队?请注意,我什至还没有编写任何引用框架的代码,我只是想让工作区配置进行编译。这是供引用的 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

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

Previously linked project dependencies

最佳答案

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

Select Main target > Build Settings > Dead Stripping code = Yes

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

关于ios - 无法使用 Firebase ML Kit 视觉文本检测器编译 iOS React Native 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50977348/

相关文章:

javascript - TextInput 中的值没有改变?

reactjs - 解决 Expo 和 React Native 的依赖冲突

ios - 将数据从 CollectionView 传递到 TabBarController,而不是在 Swift 中传递给他的 child

javascript - 为什么 Firestore 将金额存储为字符串而不是数字?

Android AppCompat-v7 和 Firestore gradle 冲突

arrays - TableView 仅显示从 Firebase 读取的部分数据

react-native - 处理 React Native 中的字体大小单位(Dp、Sp、px ..)

ios - 在不丢失部分标题的情况下更改 UITable 部分背景颜色

ios - swift 3 转换后类无法正常工作

ios - UITableView 背景色 Swift