0Pricing
Swift Academy · Lesson

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

  1. Swift Package Manager basics
  2. Layout, products & build/test/run
  3. Importing modules & semantic versioning basics
← Back to Swift Academy