Kev*_*own 10 xcode swift-package-manager
我有以下总体架构。一个为我的所有模型数据导入 Swift 包的应用程序,然后根据平台与 Firestore 一起使用或直接 REST 到 firestore。我对 WatchOS 部分使用 REST,因为 firestore-swift 仍然不支持 WatchOS。
我的 Swift 包依赖于 Firestore,这不是问题。但是,我只希望目标部分中的目标可用于 iOS 和 MacOS,而不包含在 WatchOS 上。我可以在包清单文件中指定它吗?
这是我正在尝试做的事情的总体图表。
我的包清单如下所示。请注意底部的两行注释掉的行,我只想在目标是 iOS 或 MacOS 时才包含它们。
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "EMobileLibrary",
platforms: [.iOS(.v15), .watchOS(.v8), .macOS(.v12)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "EMobileLibrary",
targets: ["EMobileLibrary"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(name: "AppDevWithSwiftLibrary", url: "https://github.com/directoryname/AppDevWithSwiftLibrary", from: "1.11.6"),
.package(
name: "Firebase",
url: "https://github.com/firebase/firebase-ios-sdk.git",
.upToNextMajor(from: "8.10.0")
),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "EMobileLibrary",
dependencies: [
.product(name: "AppDevWithSwiftLibrary", package: "AppDevWithSwiftLibrary"),
// .product(name: "FirebaseFirestore", package: "Firebase"),
// .product(name: "FirebaseFirestoreSwift-Beta", package: "Firebase")
]
),
.testTarget(
name: "EMobileLibraryTests",
dependencies: ["EMobileLibrary"]),
]
)
Run Code Online (Sandbox Code Playgroud)
Pau*_*ien 11
定义具有平台相关依赖性的虚拟包装器目标。
以下是https://github.com/firebase/firebase-ios-sdk/blob/master/Package.swift的示例摘录,它将 FirebaseDynamicLinks 定义为仅在 iOS 上可用,但在 tvOS、macOS 或 watchOS 上不可用:
.library(
name: "FirebaseDynamicLinks",
targets: ["FirebaseDynamicLinksTarget"]
),
.
.
.
.target(
name: "FirebaseDynamicLinksTarget",
dependencies: [.target(name: "FirebaseDynamicLinks",
condition: .when(platforms: [.iOS]))],
path: "SwiftPM-PlatformExclude/FirebaseDynamicLinksWrap"
),
.target(
name: "FirebaseDynamicLinks",
....
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2199 次 |
| 最近记录: |