使用 CocoaPods 和 SwiftPM 复制符号

Duplicate symbols with CocoaPods and SwiftPM

自从 Xcode11 以来,我们一直在从 CocoaPods 迁移到 SwiftPM。 不幸的是,一些依赖项还没有 SwiftPM 支持。 Like Firebase.

这不是真正的问题,因为它们可以并存。
但是因为(我认为 Firebase iOS SDK v6.13.0)他们添加了对 PromisesObjC.
的依赖 这本身不是问题,但我们的大多数项目(和(子)依赖项)通过 SwiftPm 使用 promises by google

现在的问题是 Promises SwiftPM 依赖项和 Firebase CocoaPods 都使用 FBLPromises 这将导致以下错误:

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

目前解决此问题的唯一方法是将 Firebase CocoaPods 依赖项设置为 v6.11.0

我当前的 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

将我的 google 搜索词 'cocoapods swiftpm duplicate symbols' 更改为 'cocoapods carthage duplicate symbols' 后,我遇到了一个具有不同依赖关系的类似问题。
基本上忘记了 use_frameworks! 设置。

将此添加到我的 Podfile 为我修复了它。