How to solve “duplicate symbol” when added Firebas

2020-06-09 04:19发布

问题:

I can't solve the error "duplicate symbol".

The error is

duplicate symbol _GSDK_NSClassFromString in: .../Pods/FirebaseCore/Frameworks/FirebaseCore.framework/FirebaseCore(overload_9ea29fd47bf44ee000bc4282b65dac06.o)
 /Pods/GoogleSymbolUtilities/Frameworks/frameworks/GoogleSymbolUtilities.framework/GoogleSymbolUtilities(overload.o)

duplicate symbol _GSDK_objc_getClass in: .../Pods/FirebaseCore/Frameworks/FirebaseCore.framework/FirebaseCore(overload_9ea29fd47bf44ee000bc4282b65dac06.o)
/Pods/GoogleSymbolUtilities/Frameworks/frameworks/GoogleSymbolUtilities.framework/GoogleSymbolUtilities(overload.o)

duplicate symbol _GSDK_objc_getProtocol in:    ...Pods/FirebaseCore/Frameworks/FirebaseCore.framework/FirebaseCore(overload_9ea29fd47bf44ee000bc4282b65dac06.o)
    .../Pods/GoogleSymbolUtilities/Frameworks/frameworks/GoogleSymbolUtilities.framework/GoogleSymbolUtilities(overload.o)

duplicate symbol _GSDK_objc_lookUpClass in:        ...Pods/FirebaseCore/Frameworks/FirebaseCore.framework/FirebaseCore(overload_9ea29fd47bf44ee000bc4282b65dac06.o)
    ...Pods/GoogleSymbolUtilities/Frameworks/frameworks/GoogleSymbolUtilities.framework/GoogleSymbolUtilities(overload.o)

ld: 4 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I updated and installed Podfile. But it didn't work.

Pod file

target 'game' do

  # Pods for game
  pod 'Firebase'
  pod 'Firebase/AdMob'
end

I could add Firebase before. But when I accidentally delete "FirebaseCore.framework". After that I deleted Pods and reinstalled Firebase, but it didn't work.

How can I solve it?

回答1:

I had the same issue. It seems that the -all_load flag in the Other Linker Flags is causing this.



回答2:

There was a Firebase build issue introduced in 3.11.1 that will be fixed in 3.13.0 that can cause the duplicate symbol problem. In the meantime, a workaround is to back up to Firebase 3.11.0, by annotating any Firebase subspecs in your podfile with an explicit version number, like :

pod 'Firebase/Analytics', '3.11.0'


回答3:

I solved the issue by

  1. Deleting everything from my podfile and running pod install
  2. Putting everything back in my podfile and running pod install

It's the only thing that worked for me.