Layout, products & build/test/run
Learn SwiftPM layout (Sources/ and Tests/), products (executables vs libraries), and how to build, test, and run with CLI.
Overview
This lesson shows SwiftPM layout, how products map to targets, and the CLI for build/test/run.
Folder layout
SwiftPM expects Sources/ and Tests/. Each target has its own folder.
let tree = """
MyPkg/
├─ Package.swift
├─ Sources/
│ ├─ MyLib/ // library target sources
│ │ └─ MyLib.swift
│ └─ MyApp/ // executable target sources (main.swift)
│ └─ main.swift
└─ Tests/
├─ MyLibTests/
│ └─ MyLibTests.swift
└─ MyAppTests/
└─ MyAppTests.swift
"""
print(tree)All lessons in this course
- Swift Package Manager basics
- Layout, products & build/test/run
- Importing modules & semantic versioning basics