Using Launch Arguments To Test Localizations

A quick tip for switching between localizations when testing. Updated 28-December-2013 to include details on setting the locale

Changing the Language Settings

If you have done any work with localizing an application I am sure you are familiar with changing the language of the simulator or a device from the Settings app:

Changing this setting back and forth between the different languages you need to support is tiresome if you do it manually. Luckily there is a build argument you can use to force the language at runtime.

Forcing the Required Language at Runtime

To force an application to run with a specific localization language you can pass the AppleLanguages argument to the application on launch. The argument takes the desired language as a parameter so to force the language to Spanish you would use the following:

-AppleLanguages (Spanish)

The syntax is a little fussy:

Setting the Required Locale

In addition to setting the language you can also set the locale using the AppleLocale argument:

-AppleLocale es_ES

Setting Launch Arguments

The easiest way to pass launch arguments when running from Xcode is to add them to the scheme. You can edit the current scheme from the Product > Scheme > Edit Scheme menu (or use ⌘< or option-click the Run button).

I find it useful to add an AppleLanguages argument to the Run phase of a scheme for each localization and enable the one I need. For example:

Never miss a post!

iOS Size Classes Cheat Sheet

Subscribe and get my free iOS Size Classes Cheat Sheet

Success! Now check your email to confirm your subscription and download your free guide to iOS Size Classes.

There was an error submitting your subscription. Please try again.

Unsubscribe at any time.
No time to watch WWDC videos?

Sign up to get my iOS posts direct to your inbox and I will send you a free PDF of my iOS Size Classes Cheat Sheet.

OK! Check your inbox (or spam folder) for an email to confirm your details and download your free guide to iOS Size Classes.

There was an error submitting your subscription. Please try again.

Unsubscribe at any time.
Archives Categories