Swift Command line tool to generate static strings from a Figma Design Token Json file
FigmaTokenGenerator
Swift Command line tool to generate static strings from a Figma Design Token Json file.
Installation
CocoaPods is the recommended way of installation, as this avoids including any binary files into your project.
Note on Carthage: FigmaTokenGenerator is a tool used in a build step, it is not a dynamic library. Therefore it is not possible to install it with Carthage.
CocoaPods (recommended)
- Add
pod 'FigmaTokenGenerator'
to your Podfile and runpod install
- In Xcode: Click on your project in the file list, choose your target under
TARGETS
, click theBuild Phases
tab and add aNew Run Script Phase
by clicking the little plus icon in the top left - Drag the new
Run Script
phase above theCompile Sources
phase and belowCheck Pods Manifest.lock
, expand it and paste the following script:"$PODS_ROOT/FigmaTokenGenerator/FigmaTokenGenerator" "$SRCROOT/{PATH TO YOUR JSON}/tokens.json" "$SRCROOT/{PATH TO OUTPUT}/DesignTokenIdentity.swift"
- Add
$SRCROOT/{PATH TO OUTPUT}/DesignTokenIdentity.swift
to the “Output Files” of the Build Phase - Uncheck “Based on dependency analysis” so that FigmaTokenGenerator is run on each build
- Build your project, in Finder you will now see a
DesignTokenIdentity.swift
in the$SRCROOT
-folder, drag theDesignTokenIdentity.swift
files into your project and uncheckCopy items if needed
Usage
"$PODS_ROOT/FigmaTokenGenerator/FigmaTokenGenerator" "$SRCROOT/{PATH TO YOUR JSON}/tokens.json" "$SRCROOT/{PATH TO OUTPUT}/DesignTokenIdentity.swift"