SwiftGenStrings Save

genstrings replacement for Swift that actually works

Project README


SwiftGenStrings is a command line application that can be used as a drop-in replacement for the standard genstrings command for Swift sources. The latter only supports the short form of the NSLocalizedString function but breaks as soon as you use any parameters other than key and comment as in

NSLocalizedString("DATE_RANGE", value: "%@ – %@", comment: "A range of dates")

The upstream issue is tracked here.


USAGE: SwiftGenStrings <files> ... [-s <s>] [-o <o>] [--exclude-comments]

  <files>                 List of files, that are used as source of
                          Localizable.strings generation.

  -s <s>                  (Optional) Substitute for NSLocalizedString, useful when different macro is used.
  -o <o>                  (Optional) Specifies what directory Localizable.strings table is created in. Not specifying output directory will print script output
                          content to standard output (console).
  -e, --exclude-comments  (Optional) Formatted output does not include comments
  --version               Show the version.
  -h, --help              Show help information.

To gather strings in current directory, run:

$ find . -name "*.swift" | xargs SwiftGenStrings

If you have any 3rd party code like CocoaPods or Carthage in your project directory, you might want to exclude it from localization. To do that, run the following:

$ find . \( -name "*.swift" ! -path "./Carthage/*" ! -path "./Pods/*" \) | xargs SwiftGenStrings



The quickest and easiest way to install SwiftGenStrings is via Mint

$ mint install kayak/SwiftGenStrings

Prebuilt Binaries

We tag releases and upload prebuilt binaries to GitHub. Checkout the releases tab or go straight to the latest release.

From Git

The project provides a Makefile. To export a binary run:

$ make release

The exported binary can be found under Products/SwiftGenStrings. Alternatively you can use make install to install the compiled library directly into /usr/local/bin/SwiftGenStrings


Since SwiftGenStrings is a SPM package, running tests is easy:

$ swift test


  • Xcode 12
  • Swift 5.3


  • SwiftGenStrings currently doesn't support multiple tables, only the default one - Localizable.strings.
  • It is not possible to use NSLocalizedString in string interpolation e.g.: let hello = "--- \(NSLocalizedString("Hello world!", comment: ""))" will not pickup the localized string.
Open Source Agenda is not affiliated with "SwiftGenStrings" Project. README Source: kayak/SwiftGenStrings
Open Issues
Last Commit
6 months ago

Open Source Agenda Badge

Open Source Agenda Rating