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.
- What are targets, products and modules in a Swift package, and what does a first Package.swift look like?
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.
- How do internal, package and public work between modules, and what are the classic surprises?
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
- 16.2 · SPM, CocoaPods, Carthage and XCFrameworks, and shipping binaries
- 16.3 · Static and dynamic linking, duplicate symbols, and the dependency graph
- 16.4 · Build settings, configurations, xcconfig, and compile times
- 16.5 · Resource bundles, localisation in modules, and feature flags
- 16.6 · Multi-hour CI, affected-module builds, caching, and Tuist and Bazel
- 16.7 · Version rules, pins, conflicts, unsafe flags, mirrors and inspecting the graph
- 16.8 · Conditional settings, platform minimums, language modes, traits and plugins
- 16.9 · What really crosses a module boundary: inlinable bodies and imports