通过simctl启动时如何设置iOS模拟器语言 [英] How to set iOS Simulator Language when launching via simctl

查看:169
本文介绍了通过simctl启动时如何设置iOS模拟器语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用xcrun simctl在模拟器中启动我的应用程序.我希望能够设置模拟器启动时使用的语言(例如,一次运行切换为法语,另一次运行为Englash).有没有这样做的选择?过去可以在Simulator中使用-AppleLanguages选项,但是似乎不再起作用(自Xcode 5.x起).

I am launching my app in the simulator using xcrun simctl. I would like to be able to set the language that the simulator launches with (ie. switch to French on one run, to Englash on another). Is there an option to do that? It used to be possible to use -AppleLanguages option to the Simulator, but that no longer appears to work (since Xcode 5.x).

推荐答案

我自己已经弄清楚了:

xcrun simctl launch <deviceid> <appid> -AppleLanguages "(en-GB)"

xcrun simctl launch <deviceid> <appid> -AppleLanguages \(en-GB\)

在方案中将-AppleLanguages用作启动参数时,它期望在语言标识符周围加上括号.在命令行上,bash想要解释它们,因此您要么需要对它们进行转义,要么将其用引号引起来.

When you use the -AppleLanguages as a launch argument in the scheme, it expects the parentheses around the language identifier. On the command line, bash wants to interpret them, so you either need to escape them or put the language in quotes.

只需将en-GB替换为您要使用的语言即可.

Just replace en-GB with the language you want to use.

作为引导注释,当您运行[NSLocale preferredLanguages]时,它将报告指定的语言.

As a bootnote, when you run [NSLocale preferredLanguages] it will report the specified language.

这篇关于通过simctl启动时如何设置iOS模拟器语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆