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 Phasestab and add aNew Run Script Phaseby clicking the little plus icon in the top left - Drag the new
Run Scriptphase above theCompile Sourcesphase 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.swiftto 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.swiftin the$SRCROOT-folder, drag theDesignTokenIdentity.swiftfiles 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"