We have designed a Swift Package that includes MapKit Extensions and some custom func
s that perform some Geographic computations. The intended usage would be to use a single Swift Package imported into Xcode to use two classes: one custom and the other extensions to MKMapView
.
Is it possible to create a single Swift Package that includes two or more target
s? How to properly update Package.swift
to support multiple targets?
import MapKitSwiftExtensions
import CustomGeospatialComputations
The impression is that a second target
in Package.swift
can be added in the targets
array.
.library(
name: "MapKit Swift Extensions",
targets: ["MapKitSwiftExtensions", "CustomGeospatialComputations"]
)
But when CustomGeospatialComputations
is added to the targets
array, I get this error ??:
target 'CustomGeospatialComputations' referenced in product 'MapKit Swift Extensions' could not be found
Ideally, I would like to have this file structure for development.
.
├── Package.swift
├── README.md
├── Sources
│?? └── CustomGeospatialComputations
│?? └── GeoComputations.swift
│?? └── MapKitSwiftExtensions
│?? └── MKMapView+Extensions.swift
This is the Package.swift
that works (without CustomGeospatialComputations
)
// swift-tools-version:5.2
import PackageDescription
let package = Package(
name: "MapKit Swift Extensions",
products: [
.library(
name: "MapKit Swift Extensions"],
targets: ["MapboxSwiftExtensions"),
],
dependencies: [ ],
targets: [
.target(
name: "MapKitSwiftExtensions",
dependencies: []),
]
)
question from:
https://stackoverflow.com/questions/65887860/create-a-single-swift-package-that-includes-two-or-more-targets 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…