Supercharge Swift with SwiftGen

The Swift code generation tool for colors, images, strings & more!

let image = Image("my-cool-image") // Stop doing this 😡
// swiftgen.ymlxcassets:
- YourProjectName/Assets.xcassets // 1
templateName: swift5 // 2
output: ProjectName/Assets.swift // 3
  1. The asset catalog file. You can also add colors to the asset catalog with the images.
  2. The template you are using, run swiftgen template list to try them out.
  3. The output file name for the generated code.
generated swift code, ty swiftgen!
let image = Image(Asset.myCoolImage) // Do this 😎
// swiftgen.ymlstrings:
inputs: TemplateProject/Localizable.strings // 1
- templateName: structured-swift5
output: TemplateProject/Generated/Strings.swift
  1. Input file where you can put all your strings, it’s important to namespace them here like this (the rest is the same as above):
var body: some View {
Text(L10n.Onboarding.Buttons.join) // 🎉

⚠️ You can also concatenate Strings if they are dynamic using %@ in the Localizable.strings file.

- YourProjectName/Assets.xcassets
templatePath: xcassets-swiftui.stencil // 1
output: ProjectName/Assets.swift
  1. Update the swiftgen.yml templateName field to templatePath above and point to the file after adding it to the project root (GH link above).
var body: some View {
.cornerRadius(10) // this compiles
🔊 audio narration

Shameless plug: if you enjoyed this check my Patreon or YouTube for tutorials and posts I make around Swift and swe’ing in general 😎



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store