1

Ever since Xcode11 we've been migrating from CocoaPods to SwiftPM. Unfortunately some of the dependencies don't have SwiftPM support yet. Like Firebase.

This isn't a real problem, since both of them can coexist next to eachother.
But since (I think Firebase iOS SDK v6.13.0) they added a dependency to PromisesObjC.
Which in itself isn't a problem, but most of our projects (and (sub)dependencies) use promises by google through SwiftPm.

Now the problem is that both the Promises SwiftPM dependency and Firebase CocoaPods one uses FBLPromises and this will result in the following error:

duplicate symbol '_FBLPromiseRetryDefaultAttemptsCount' in:
    /path/Products/Debug-iphonesimulator/FBLPromises.o
    /path/Products/Debug-iphonesimulator/PromisesObjC/libPromisesObjC.a(FBLPromise+Retry.o)
duplicate symbol '_FBLPromiseRetryDefaultDelayInterval' in:
    /path/Products/Debug-iphonesimulator/FBLPromises.o
    /path/Products/Debug-iphonesimulator/PromisesObjC/libPromisesObjC.a(FBLPromise+Retry.o)
duplicate symbol '_FBLWaitForPromisesWithTimeout' in:
    /path/Products/Debug-iphonesimulator/FBLPromises.o
    /path/Products/Debug-iphonesimulator/PromisesObjC/libPromisesObjC.a(FBLPromise+Testing.o)
duplicate symbol '_OBJC_CLASS_$_FBLPromise' in:
    /path/Products/Debug-iphonesimulator/FBLPromises.o
    /path/Products/Debug-iphonesimulator/PromisesObjC/libPromisesObjC.a(FBLPromise.o)
duplicate symbol '_OBJC_METACLASS_$_FBLPromise' in:
    /path/Products/Debug-iphonesimulator/FBLPromises.o
    /path/Products/Debug-iphonesimulator/PromisesObjC/libPromisesObjC.a(FBLPromise.o)
ld: 5 duplicate symbols for architecture x86_64

Currently the only way to fix this is to set the Firebase CocoaPods depenceny to v6.11.0

My current Podfile:

source 'git@github.com:CocoaPods/Specs.git'

workspace 'Workspace'

platform :ios, '11.0'

use_modular_headers!
inhibit_all_warnings!

install! 'cocoapods',
    :generate_multiple_pod_projects => true,
    :incremental_installation => true

target 'HandpickedFamilyApp' do
    pod 'Firebase/Core'
    pod 'Firebase/RemoteConfig'
    pod 'Firebase/Analytics'
    pod 'Firebase/Performance'
    pod 'Fabric'
    pod 'Crashlytics'
    pod 'SwiftLint'

    script_phase :name => 'Run Fabric',
                :script => '"${PODS_ROOT}/Fabric/run"',
                :input_files => ['$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)']
end
basvk
  • 4,437
  • 3
  • 29
  • 49

2 Answers2

0

After changing my google search term 'cocoapods swiftpm duplicate symbols' with 'cocoapods carthage duplicate symbols' I came up with a similar problem with a different dependency.
And essentially forgot all about the use_frameworks! setting.

Adding this to my Podfile fixed it for me.

basvk
  • 4,437
  • 3
  • 29
  • 49
0

Using use_frameworks! in the Podfile helps you get rid of the duplicate symbols error in the question, but this time I ended up with many warnings in my console:

Class is implemented in both, One of the two will be used. Which one is undefined

After trying many things, I have solved these problems by installing both Firebase and Google AdMobs SDK via Cocoapods (without using Swift Package Manager).

  1. Remove Firebase from the package dependencies

  2. Edit your Podfile as follows:

     pod 'FirebaseAnalytics'
     # Or, to not use AdId:
     # pod 'Firebase/AnalyticsWithoutAdIdSupport'
     pod 'Google-Mobile-Ads-SDK'
    
Luke
  • 965
  • 8
  • 21