Will I be able to restart my iPhone app programatically to apply language changes in Swift

18,789

Solution 1

Swift is a language, not an API. You have the same functionality available to you in Swift as in Objective C, although the syntax and ease of use may differ between the languages.

The answer you linked to therefore already answers the question.


Also, as Hemang points out, don't do this.

It's symptomatic of bad design that you would need to restart the app to change the displayed language. It would be much better to fix the underlying problem than to apply a hacky band-aid solution such as this.

Solution 2

DONT EVER DO THIS... else you'll surely reject by Apple, I don't know what problem you're facing after user change different language from your app, because I'd worked on this kind of app before (which supports multiple language and user may able to change it while current running of the app). I don't have idea with Swift but in ObjectiveC it works perfect.

From Documentation, https://developer.apple.com/library/ios/qa/qa1561/_index.html

Warning: Do not call the exit function. Applications calling exit will appear to the user to have crashed, rather than performing a graceful termination and animating back to the Home screen.

NOT RECOMMENDED but still, you can ask user to Restart their app whenever they changed the language with proper message like, " needs to restart to take effect of language change, [please save your any on going work] and close and again open the app to see the effect, thanks !"

Here, the words inside <...> should be your app name, and [...] need to show if you're making an app that needs to save user information before exit?.

Share:
18,789

Related videos on Youtube

Muralidharan Kathiresan
Author by

Muralidharan Kathiresan

Updated on July 04, 2022

Comments

  • Muralidharan Kathiresan
    Muralidharan Kathiresan almost 2 years

    I am developing an iPhone app in swift and wanted localisation feature inside it. When the user selects a language in the app, the UI components such as labels/buttons,etc.,. fails to change the language and takes more time in some cases also. So i needed to manually restart my app when the users want to change the language. Can anyone please suggest me how to do that. Thanks in advance.

  • Muralidharan Kathiresan
    Muralidharan Kathiresan over 9 years
    Thanks @sapi that helped me a lot