I'm moving my Carthage libraries to Swift Package Manager. If my Swift Package has dependencies to other Swift Packages, do I have to explicitly link those libraries into the project like I do with Carthage, or are the nested dependencies embedded in the Swift Package?
Asked
Active
Viewed 570 times
8
-
Did you ever find an answer to this? – SirRupertIII Sep 18 '20 at 08:24
1 Answers
0
You can create a target for each dependency (if not exist) and then add them as a dependency. For example, take a look at this:
let package = Package(
name: "SMUIKit",
products: [
.library(
name: "SMUIKit",
targets: ["SMUIKit"]),
.library(
name: "SMStyleKit",
targets: ["SMStyleKit"]),
],
dependencies: [
.package(name: "ExistDependency", url: "https://github.com/mojtabahs/ExistDependency", from: "5.0.0"),
],
targets: [
.target(
name: "SMUIKit",
dependencies: ["SMStyleKit"]
),
.target(
name: "SMStyleKit",
dependencies: ["ExistDependency"],
resources: [.process("Resources")]
),
]
)
In this package.swift
:
SMUIKit
andSMStyleKit
are libraries that this package creates.ExistDependency
is a package that already exists.SMUIKit
depends on the generatedSMStyleKit
.SMStyleKit
depends on theSMStyleKit
.
I tried to cover some dependency situations but you can R&D more about how you can achieve your needs.

Mojtaba Hosseini
- 95,414
- 31
- 268
- 278