Skip to content
Studio

0005. Swift tokens generated from the spec

Status: Accepted · 2026-10-17

Context

StudioKit 1.x shipped a hand-maintained StudioTokens.swift that drifted from the web; its ROADMAP records an invented StudioSpace.s7 that broke the first real compile. Neue Glass shows a Swift generator beside the CSS one. No Swift toolchain runs in this repository's checks.

Decision

studio swift --out packages/swift/Sources/StudioKit/Generated/StudioTokens.swift generates every group of the spec for SwiftUI: colours as light and dark dynamic Colors, converted from OKLCH to sRGB and written in Display P3 where a colour is outside sRGB; spacing, radii, thresholds; type roles with exact PostScript names read from the font files; motion, z-order, elevation, materials, density and component metrics. Its naming rules are printed at the top of the file. --check fails on drift, and tools/swift-syntax.mjs parses it and checks that every Studio token name used in Swift exists in it.

Consequences

  • StudioKit cannot name a token the spec does not have without failing make validate.
  • CSS values with no Swift form (ch, vw, %) are listed in the file, not guessed.
  • The file is parsed, not compiled, until Xcode builds it (Apple).
Contents