Quickstart-ios: MLVisionTextModel duplicate symbols with React Native

Created on 10 Jul 2018  路  8Comments  路  Source: firebase/quickstart-ios

I'm building an app with React Native that I've already "ejected" into its own native app project for iOS. I'm interested in using the new Firebase ML Kit Vision Text Detector for recognizing text in images using the on-device model, and I'm willing to write my own NativeModule wrapper for it (since it's so new, I don't see any existing wrappers in projects like react-native-firebase).

So, I used Cocoapods to bring in the Firebase dependencies, but when I try to compile the new workspace, I get the following linker error:

duplicate symbol __ZN3fLB28FLAGS_nosymbolize_stacktraceE in:
    /Users/zainsajjad/Desktop/development/ios/Pods/GoogleMobileVision/TextDetector/Frameworks/TextDetector.framework/TextDetector(examine_stack_b03c119c7358b452600b1afd20ca186c.o)
    /Users/zainsajjad/Library/Developer/Xcode/DerivedData/app-hfkgohktkkwcwocawuqzpgjzslrk/Build/Products/Debug-iphonesimulator/libReact.a(utilities.o)
duplicate symbol __ZN3fLB26FLAGS_symbolize_stacktraceE in:
    /Users/zainsajjad/Desktop/development/ios/Pods/GoogleMobileVision/TextDetector/Frameworks/TextDetector.framework/TextDetector(examine_stack_b03c119c7358b452600b1afd20ca186c.o)
    /Users/zainsajjad/Library/Developer/Xcode/DerivedData/app-hfkgohktkkwcwocawuqzpgjzslrk/Build/Products/Debug-iphonesimulator/libReact.a(utilities.o)
duplicate symbol __ZN3fLB18FLAGS_nolog_prefixE in:
    /Users/zainsajjad/Desktop/development/ios/Pods/GoogleMobileVision/TextDetector/Frameworks/TextDetector.framework/TextDetector(logging_2072041cb58f7b92d4eb8dae33e75a0d.o)
    /Users/zainsajjad/Library/Developer/Xcode/DerivedData/app-hfkgohktkkwcwocawuqzpgjzslrk/Build/Products/Debug-iphonesimulator/libReact.a(logging.o)
duplicate symbol __ZN3fLB16FLAGS_log_prefixE in:
    /Users/zainsajjad/Desktop/development/ios/Pods/GoogleMobileVision/TextDetector/Frameworks/TextDetector.framework/TextDetector(logging_2072041cb58f7b92d4eb8dae33e75a0d.o)
    /Users/zainsajjad/Library/Developer/Xcode/DerivedData/app-hfkgohktkkwcwocawuqzpgjzslrk/Build/Products/Debug-iphonesimulator/libReact.a(logging.o)
duplicate symbol __ZN3fLI9FLAGS_novE in:
    /Users/zainsajjad/Library/Developer/Xcode/DerivedData/app-hfkgohktkkwcwocawuqzpgjzslrk/Build/Products/Debug-iphonesimulator/libReact.a(vlog_is_on.o)
    /Users/zainsajjad/Desktop/development/ios/Pods/GoogleMobileVision/TextDetector/Frameworks/TextDetector.framework/TextDetector(vlog_is_on_ec23571a5409c45b7e2ca681c18af4cb.o)
duplicate symbol __ZN3fLI7FLAGS_vE in:
    /Users/zainsajjad/Library/Developer/Xcode/DerivedData/app-hfkgohktkkwcwocawuqzpgjzslrk/Build/Products/Debug-iphonesimulator/libReact.a(vlog_is_on.o)
    /Users/zainsajjad/Desktop/development/ios/Pods/GoogleMobileVision/TextDetector/Frameworks/TextDetector.framework/TextDetector(vlog_is_on_ec23571a5409c45b7e2ca681c18af4cb.o)
duplicate symbol __ZN3fLS13FLAGS_vmoduleE in:
    /Users/zainsajjad/Library/Developer/Xcode/DerivedData/app-hfkgohktkkwcwocawuqzpgjzslrk/Build/Products/Debug-iphonesimulator/libReact.a(vlog_is_on.o)
    /Users/zainsajjad/Desktop/development/ios/Pods/GoogleMobileVision/TextDetector/Frameworks/TextDetector.framework/TextDetector(vlog_is_on_ec23571a5409c45b7e2ca681c18af4cb.o)
ld: 7 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This issue appears when I add 'Firebase/MLVisionTextModel' in podspecs.
In case I don't add this as a dependency, it returns an empty array on the images having a good amount of text!

Most helpful comment

Hi @zsajjad ! I had the exact same issue using react native and I solved enabling the dead code stripping in xcode for debug. You can enable it in Target > Build Settings > search for "Dead code stripping". For now seems to work fine.

All 8 comments

By podspec do you mean Podfile? Can you share your Podfile? TextDetector is a static dependency and it looks like it's being linked twice into your project.

Update: it looks like GMV and React Native have a shared c++ dependency that's causing these symbol collisions. It's unlikely that there are good workarounds for this on your end, so you'll probably have to wait for a Firebase (or RN) fix.

I'll keep this issue updated.

I am trying to publish a wrapper for MLKit Vision for React Native. Here is the podspec.

I also tried

  s.dependency     'Firebase/Core'
  s.dependency     'Firebase/MLVision'
  s.dependency     'Firebase/MLVisionTextModel'

My Project's Podfile looks like this:

platform :ios, '11.3'

target 'myApp' do
  rn_path = '../node_modules/react-native'
  rn_maps_path = '../node_modules/react-native-maps'

  # See http://facebook.github.io/react-native/docs/integration-with-existing-apps.html#configuring-cocoapods-dependencies
  pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec"
  pod 'React', path: rn_path, subspecs: [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
  ]

  pod 'RNTextDetector', path: '../node_modules/react-native-text-detector/ios'
  pod 'react-native-camera', path: '../node_modules/react-native-camera'
  pod 'lottie-ios', :path => '../node_modules/lottie-ios'
  pod 'lottie-react-native', :path => '../node_modules/lottie-react-native'
  pod 'react-native-maps', path: rn_maps_path
  pod 'react-native-google-maps', path: rn_maps_path 

  # React Native third party dependencies podspecs
  pod 'DoubleConversion', :podspec => "#{rn_path}/third-party-podspecs/DoubleConversion.podspec"
  pod 'glog', :podspec => "#{rn_path}/third-party-podspecs/glog.podspec"
  pod 'Folly', :podspec => "#{rn_path}/third-party-podspecs/Folly.podspec"

  # react-native-maps dependencies
  pod 'GoogleMaps'
  pod 'Google-Maps-iOS-Utils'
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'react-native-google-maps'
      target.build_configurations.each do |config|
        config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
      end
    end
    if target.name == "React"
      target.remove_from_project
    end
  end
end

Sorry any news on problem?
I have the same problem with nativa app ios in swift.
Any idea?

@rmusetti81 you should not be running into this issue when developing a native app in Swift. Please open a new issue with all of your build information (Podfile, Podfile.lock, CocoaPods version, Xcode version).

Hi @zsajjad ! I had the exact same issue using react native and I solved enabling the dead code stripping in xcode for debug. You can enable it in Target > Build Settings > search for "Dead code stripping". For now seems to work fine.

I made my own package that uses firebase ml vision on android and CoreML+TesseractOCR on ios!

@joan-domingo's solution works fine.
For people looking here, you can use react-native-text-detector firebase branch as a wrapper around firebase ML Kit Vision.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zjlxgxz picture zjlxgxz  路  9Comments

mingsai picture mingsai  路  5Comments

svachmic picture svachmic  路  5Comments

kamrankhan07 picture kamrankhan07  路  7Comments

EthanDoan picture EthanDoan  路  6Comments