如何在 Swift 包管理器中排除对 Catalyst 的依赖?

nul*_*ion 9 ios swift

有一个包含 Catalyst 的 ios 项目。该项目具有无法针对 mac 架构进行编译的YandexMobileMetrica依赖项。如何使用 Swift Package Manager 添加仅限 iOS 的依赖项?

我尝试做两个目标。在第一个spm-test中,我禁用了 mac 标志。在第二个中,spm-test-mac离开了。我的 Package.swift 看起来像这样:

import PackageDescription

let package = Package(
    name: "spm-test",
    products: [
        .library(
            name: "spm-test",
            targets: ["spm-test"]),
    ],
    dependencies: [
        .package(name: "YandexMobileMetrica", url: "https://github.com/yandexmobile/metrica-sdk-ios", from: "3.14.1"),
    ],
    targets: [
        .target(
            name: "spm-test",
            dependencies: ["YandexMobileMetrica"]),
        .target(
            name: "spm-test-mac",
            dependencies: [])
    ]
) 
Run Code Online (Sandbox Code Playgroud)

错误:

AppDelegate.swift:11:12: No such module 'YandexMobileMetrica'
Run Code Online (Sandbox Code Playgroud)

我的 AppDelegate.swift

//  AppDelegate.swift
//

import UIKit

#if !targetEnvironment(macCatalyst)
    import YandexMobileMetrica //  Error here
#endif
Run Code Online (Sandbox Code Playgroud)