0

On the app that I develop I want to have english and greek in debug mode (because I don't speak greek and the app is for Greece) and only Greek when when in release( because I have a requirement to only support Greek and no english when the app is released).

So, does anyone know how can I do this in iOS?

razvan
  • 355
  • 4
  • 19

2 Answers2

1

Solution 1

One easy thing I would do :

  • Create a new branch for production
  • Remove the English language in the project while keeping the files

Now every time you merge into prod, it will be up-to-date without the English language available. NB: Don't forget to switch back to your dev branch while you are coding!

Solution 2

If you can't use another branch, you can create a Build Run Script that will get executed every time you build the app and/or use Fastlane to customise your deployment pipeline

cyril94440
  • 1,057
  • 1
  • 9
  • 22
  • I also suggested this solution, but automated build for end to end testing should also be only in english and that is done from the same branch we do development and sadly I don't think I can use this solution, but I will keep it as a backup – razvan Feb 13 '19 at 10:33
  • 1
    Maybe you should create your own Build Run Script to clean whatever you need to clean – cyril94440 Feb 13 '19 at 10:46
1

After all I inspired a little from this thread, more exactly this answer.

And here is how my solution looks:

Removed @UIApplicationMain from AppDelegate and created main.swift and added this code:

if !SharedConstants.isDebugEnabled {
    let supportedLanguages: [String] = ["el"]
    UserDefaults.standard.set(supportedLanguages, forKey: "AppleLanguages")
    UserDefaults.standard.synchronize()
}
UIApplicationMain(CommandLine.argc, CommandLine.unsafeArgv, nil, NSStringFromClass(AppDelegate.self))

LATER EDIT:

Later I found the solution to add the below script in Build Phases to remove the english language and I don't need any of the workarounds above.

if [ $CONFIGURATION == 'Release' ]; then
    rm -r "${TARGET_BUILD_DIR}/${PRODUCT_NAME}.app/en.lproj"
fi;
razvan
  • 355
  • 4
  • 19