I am diving into dependency management with SPM, here is my Package.swift
let package = Package(
name: "MyPackage",
products: [
.library(
name: "MyPackage",
targets: ["MyPackage"]),
],
targets: [
.target(
name: "MyPackage",
path: "Sources") // it targets a whole folder
]
)
The thing is that, since I am building a personal Package which gathers a lot of different utility methods and classes that are not interdependent, I want to be able to split it into different "modules" or "imports".
For instance, I have 2 subfolders in Sources
: Widgets
and Networking
. The first one gathers all my UIView / UIControls widgets, and in the second one a bundle of protocols that helps me building API class.
I want to be able to split those two into two imports, considering that I sometime don't need one or the other in my projects. making it feasible to write import MyPackageNetworking
and import MyPackageWidgets
I tried:
let package = Package(
name: "MyPackage",
platforms: [
.iOS(.v14)
],
products: [
.library(
name: "MyPackage",
targets: ["MyPackageNewtorking", "MyPackageWidgets"]),
],
targets: [
.target(
name: "MyPackageNewtorking",
path: "Sources/Newtorking"),
.target(
name: "MyPackageWidgets",
path: "Sources/Widgets")
]
)
but no luck on this side. Does anyone know how to do this?