I get a warning while building my swift package.
I have Package.swift:
import PackageDescription
let package = Package(
name: "MyPackage",
platforms: [.iOS(.v15)],
products: [
.library(
name: "MyPackage",
targets: ["MyPackage"]),
],
dependencies: [
.package(name: "Lottie", url: "https://github.com/airbnb/lottie-spm.git", from: "4.5.0")
],
targets: [
.target(
name: "MyPackage",
dependencies: ["Lottie"]
),
.testTarget(
name: "MyPackage Tests",
dependencies: ["MyPackage"]),
]
)
And I get warning:
'package(name:url:from:)' is deprecated: use package(url:from:) instead
But if I use package(url:from:)
, like:
.package(url: "https://github.com/airbnb/lottie-spm.git", from: "4.5.0")
I get error:
product 'Lottie' required by package 'mypackage' target 'MyPackage' not found. Did you mean 'Lottie'?
How it can be resolved in right way?
You need to add the dependency like this:
...
dependencies: [
.package(name: "Lottie", url: "https://github.com/airbnb/lottie-spm.git", from: "4.5.0")
],
targets: [
.target(
name: "MyPackage",
dependencies: [
.product(name: "Lottie", package: "lottie-spm"), // <<<< HERE
],
...
NOT like this:
dependencies: ["Lottie"],