Skip to content

peterfriese/swift-book

 
 

Repository files navigation

The Swift Programming Language

Download PDF

Cover Table of Contents Control Flow (While Loops) Page 1 Control Flow (While Loops) Page 2 Control Flow (While Loops) Page 3

This repository contains the source for The Swift Programming Language (sometimes abbreviated as TSPL), which is published on docs.swift.org and built using Swift-DocC.

This fork creates a beautiful, printable PDF edition using Typst.

Contributing

For small changes, like typo fixes and changes to a few paragraphs, fork this repository and make a pull request.

A formal contribution process for this document is still in development. In the meantime, start a pitch thread in the Swift forums for larger changes to discuss your approach and identify possible issues before you invest a lot of time in writing.

Content in this book follows Apple Style Guide and this book’s style guide.

File bugs about the content using the issues page on Github.

Discussions and contributions follow the Swift Code of Conduct.

For more information, see Contributing to The Swift Programming Language.

Building

Run docc preview TSPL.docc in this repository's root directory.

After running DocC, open the link that docc outputs to display a local preview in your browser.

Note:

If you installed DocC by downloading a toolchain from Swift.org, docc is located in usr/bin/, relative to the installation path of the toolchain. Make sure your shell's PATH environment variable includes that directory.

If you installed DocC by downloading Xcode, run xcrun docc preview TSPL.docc instead.

Building the PDF

The PDF is built automatically on every push to the pdf-edition branch and attached to Releases. You generally do not need to build it manually.

However, if you want to build a local copy:

Prerequisites

Tool Version Notes
Python 3.10+ Required for migration scripts.
Typst 0.13.0+ Install Typst
Gemini API Key Optional Set GEMINI_API_KEY for AI-generated chapter eyebrows.

Build Command

We provide a unified build script that handles everything for you:

bin/build-pdf

This command will:

  1. Check for required tools and download fonts if missing.
  2. Convert the source content from DocC to Typst format (stored in generated/).
  3. Compile the final PDF to swift-book.pdf in the root directory.

About

The Swift Programming Language book as a PDF!

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Markdown 58.0%
  • HTML 38.0%
  • Swift 2.4%
  • Python 1.0%
  • Shell 0.4%
  • Typst 0.2%