✓ Step-up Series — Localization management in Xcode using swift

Alex Pinhasov
2 min readDec 10, 2020

--

I can safely say most of the apps today use localization to support languages, this is welcomed and encouraged to make sure you reach the biggest audience you can.

Most of the times the localization files (a.k.a .strings) tent to get big very fast, and with size comes chaos represented as:

✖︎ Keys are not sorted.

✖︎ You might have duplicate values for different keys

✖︎ You don't know which keys are being used.

✖︎ You don't know if the keys you use in your project actually exist in .strings file

✖︎ You dont know if all the localization files have matching keys to make sure your text is translated in all supported languages.

✖ You don’t know if the new keys entered use a convention you’re project follows.

The list can go on and on, but the point is Xcode doesn't help you manage it and honestly developers cant go and waste time finding all of those issues.

I had the same problem with my project at work, yes we are using SwiftLint and that’s a great framework, you can even add you own rules but it doesn't do everything I listed above, you might succeed in writing a few rules to cover some issues.

But the problem I am trying to solve it the validation rules between the project files(.swift, .xib…) AND the localization files (.strings).

So what were my guiding rules:

  1. Easy integration.
  2. Simple, short, readable code written in swift.
  3. Run on every build.
  4. Use Swift package manager.
  5. See the errors/warning in Xcode natively, point out what the issue and where.
  6. Customisable

I decided to create a new framework called “AutoLocalized” to solve that, I created an executable package using swift that runs on every build using Xcode build phases run script.

I am adding a link to the framework, check it out, I am always happy to get good/bad criticism.

There are a lot of possibilities and ideas I want to add to the framework, but the core functionality works, and it works great! check it out.

--

--

Alex Pinhasov

Senior iOS Developer, I think.