16.1 · Targets, products, modules, and access across module boundaries

A Swift package is a manifest that declares what code exists, how it is grouped, and what is offered to others. Understanding the three words target, module and product removes most of the confusion.

Mental model. A target is a unit of compilation that becomes a module. A product is what a package offers to the outside. Access control is enforced at module boundaries.

Your first package

Manifest, targets, products and modules.

  1. What are targets, products and modules in a Swift package, and what does a first Package.swift look like? 16.1.1 · L3
    A package’s Package.swift is Swift code that builds a Package value. Its three central ideas: a target is a directory of sources compiled together with its own…

Across the boundary

<code>internal</code>, <code>package</code> and <code>public</code> between modules.

  1. How do internal, package and public work between modules, and what are the classic surprises? 16.1.2 · L3
    Access control is enforced at the module boundary. internal (the default) means “visible inside this module”, so another target that imports it cannot see an…

More in Modularization & SPM