Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to compile iOS React Native app with Firebase ML Kit Vision Text Detector

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/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

From what I've read on other cases of duplicate symbols errors in React Native projects, this is usually caused by including pods that depend on the React in addition to having the React project manually linked to the main app project (as it is initially set up after eject, along with other libraries linked using react-native link). However, that's not the case here- the only libraries I'm pulling in through the podfile are Firebase related, so I'm not sure how conflicts are happening.

Any insight from anyone- perhaps from the Firebase team working on the new ML Kit for iOS? Note that I have not even written any code yet that references the framework, I'm just trying to get the workspace configuration to compile. Here's the podfile for reference:

# 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

And here's a screenshot of all the linked library projects in the main app project:

Previously linked project dependencies

like image 365
Francis Li Avatar asked Jun 21 '18 20:06

Francis Li


1 Answers

I got the same issue when applying ML kit to RN project. Here is the solution:

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

Hope it will get you through.

like image 162
d4rkwinz Avatar answered Oct 17 '22 18:10

d4rkwinz