Swift

Generate Swift asset catalogs from DTCG tokens.

Setup

Requires Node.js 18 or later. With that installed, and a package.json, run:

npm i -D @terrazzo/cli @terrazzo/plugin-swift

Add a terrazzo.config.js to the root of your project with:

import { defineConfig } from "@terrazzo/cli";
import swift from "@terrazzo/plugin-swift";

export default defineConfig({
  outDir: "./tokens/",
  plugins: [
    swift({
      catalogName: "Tokens",
    }),
  ],
});

Lastly, run:

npx tz build

And you’ll see a ./tokens/Tokens.xcassets catalog generated in your project. Import it into your project and you’ll have access to all your tokens!

Contents

  1. Setup