How to launch iOS Simulator in specific language from command line?

风流意气都作罢 提交于 2019-12-29 07:48:14

问题


I need to lauch iOS Simulator that uses specific language using command line. So I found that I can use

instruments -w <device>

and it is working great, I can set specific device. But how can I run simulator with specific language? I've tried adding

-AppleLanguages -AppleLocale

but there are some warnings:

Instruments Usage Error : Specified target process is invalid: -AppleLanguage

thanks!


回答1:


To run your app must be installed and located (if not, will open default language)

Use this command to run your app with some language

xcrun simctl launch <deviceid> <appid> -AppleLanguages "(pt-BR)"

Sample:

xcodebuild -sdk iphonesimulator8.4 -arch i386 install DSTROOT=SomeFolder
xcrun instruments -w "iPhone 6 (8.4 Simulator)"
xcrun simctl install booted SomeFolder/Applications/YourApp.app
xcrun simctl launch booted com.yourdomain.yourapp -AppleLanguages "(pt-BR)"



回答2:


The only way to launch iOS Simulator with specific language is to change contents of its .GlobalPreferences.plist file. Using xcrun tool will not work because it passess arguments to launched app and not changing language of simulator itself. Manipulation on .GlobalPreferences.plist is quite difficult because it is a binary plist file, so you cannot modify it as 'normal' xml. The easiest way to change its contents is to write simple Xcode Command Line Tool application, Foundation SDK has all tools needed to modify binary plists.




回答3:


Have a look at:

https://developer.apple.com/library/ios/documentation/MacOSX/Conceptual/BPInternational/TestingYourInternationalApp/TestingYourInternationalApp.html Search for "Testing Specific Languages and Regions"

Perhaps it could also be a solution creating different targets. Each target has configured another language



来源:https://stackoverflow.com/questions/31428132/how-to-launch-ios-simulator-in-specific-language-from-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!