Skip to content

xavierLowmiller/xcode-dead-strings

Repository files navigation

Xcode Dead Strings

Find dead localized strings in your Xcode project

Installing

Brew

brew install xavierLowmiller/tap/xcode-dead-strings

From Source

Clone this project and run swift build -c release

Supports

  • Swift
    • "Regular Strings"
    • """Multiline Strings"""
    • #"Raw Strings"#
  • Objective-C(++)
  • Info.plist keys
  • Storyboards / xibs
  • .intentDefinition files

Use cases

List all dead Strings by file

xcode-dead-strings

Create Xcode warnings for dead Strings

xcode-dead-strings --xcode-warnings

Immediately delete all identified dead Strings

xcode-dead-strings --delete

Options

▶ xcode-dead-strings --help

USAGE: xcode-dead-strings [<path>] [--silent] [--delete] [--xcode-warnings] [--source-path <source-path>] [--localization-path <localization-path>]

ARGUMENTS:
  <path>                  The root path of the iOS directory (default: .)

OPTIONS:
  --silent                Should output be silenced? 
  --delete                Delete dead strings from .strings files automatically 
  --xcode-warnings        Show dead strings as warnings in Xcode 
  --source-path <source-path>
                          Path containing the source files to be searched 
  --localization-path <localization-path>
                          Path containing the localization files to be searched 
  -h, --help              Show help information.

Limitations ⚠️

This command line tool can only detect static strings. If you compute your localized String keys dynamically, they won't be detected by xcode-dead-string, so this won't work:

var key = "my_string_key"
if foo {
  key += "_1"
} else {
  key += "_2"
}

You can work around this by either restructuring your code to only have static Strings:

let key: String
if foo {
  key = "my_string_key_1"
} else {
  key = "my_string_key_2"
}

Or you can ignore the keys from xcode-dead-strings by adding a comment in your Localizable.strings file:

/* no_dead_string */
"my_string_key_1" = "...";

// no_dead_string
"my_string_key_1" = "...";