Swift

Generate Swift asset catalogs from DTCG tokens.

warning

This plugin is still experimental. If you have suggestions, or would like to contribute, please open an issue or say “hi” in Discord!

Setup

Requires Node.js. 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