Eric Roller's blog

Thursday, September 17, 2015

Auto-generating the Storyboard.strings File

This is what I now use to auto-generate the default Main.strings file for my “Base”-localized storyboard.

Basically, whenever the storyboard file is updated, I re-generate the strings file. Most of the time, the resulting strings file doesn’t change, but when it does, I use Xcode’s version editor to highlight the changes since my last (version control) check-in. I can then make the appropriate changes to the other strings files for all the languages that the project supports.

Here is the build-phase script to Xcode:

Xcode : (Project Navigator) : (Select your Project) : (Select your Target) : Build Phases : (”+” Button) : New Run Script Phase

Change the title to: Re-generate Storyboard Strings File

Shell: /bin/bash



# If the strings file is missing or empty, or
# if the storyboard is more recent:
if [[ ! -n $str_out || $nib_in -nt $str_out ]]; then
  echo "Re-generating: $str_out"
  ibtool --export-strings-file $str_out $nib_in

[On] Show environment variables in build log
[Off] Run script only when installing

Input Files

Output Files