Since Swift 5.6, the method package(name:url:_:)
to define a Swift package dependency has been deprecated. The new recommended way to define a dependency is to use package(url:from:)
.
With that new method, we can no longer specify an explicit name for the package. Before we defined the Datatrans dependency as follows with an explicit name Datatrans
:
// swift-tools-version:5.5
import PackageDescription
let package = Package(
name: "example",
products: [
.library(name: "example", targets: ["example"]),
],
dependencies: [
.package(name: "Datatrans", url: "https://github.com/datatrans/ios-sdk.git", .upToNextMajor(from: "1.5.1")),
],
targets: [
.target(
name: "example",
dependencies: [
.product(name: "Datatrans"),
]
),
]
)
Now with the new recommended method we can no longer explicitly name the dependency. It defaults to the repo name. If the names of the product (here Datatrans
) and the package (here ios-sdk
) don't coincide, we have to explicitly name the package when listing the dependency in the target:
// swift-tools-version:5.5
import PackageDescription
let package = Package(
name: "example",
products: [
.library(name: "example", targets: ["example"]),
],
dependencies: [
.package(url: "https://github.com/datatrans/ios-sdk.git", from: "1.5.1"),
],
targets: [
.target(
name: "example",
dependencies: [
.product(name: "Datatrans", package: "ios-sdk"),
]
),
]
)
The package name ios-sdk
is too broad and at risk of clashing with other packages. Thus, I'd suggest to rename the repo to something containing datatrans
, e.g. datatrans-ios
or datatrans-ios-sdk
.