xcode 如何从命令行启动特定语言的iOS模拟器?

jm81lzqq  于 2023-03-09  发布在  iOS
关注(0)|答案(4)|浏览(194)

我需要使用命令行来启动使用特定语言的iOS模拟器。所以我发现我可以使用

instruments -w <device>

它工作得很好,我可以设置特定的设备。但是我如何用特定的语言运行模拟器呢?我试过添加

-AppleLanguages -AppleLocale

但也有一些警告:

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

谢谢!

2w2cym1i

2w2cym1i1#

使用特定语言启动iOS Simulator的唯一方法是更改其.GlobalPreferences.plist文件的内容。使用xcrun工具将不起作用,因为它将参数传递给启动的应用程序,而不更改模拟器本身的语言。在.GlobalPreferences.plist上操作相当困难,因为它是一个二进制plist文件,所以你不能把它修改成“普通的”xml。修改它的内容最简单的方法是写简单的Xcode Command Line Tool application,Foundation SDK有修改二进制plists所需的所有工具。

klr1opcd

klr1opcd2#

要运行您的应用程序必须安装和定位(如果没有,将打开默认语言)
使用此命令以某种语言运行应用程序

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

样品:

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)"
3gtaxfhh

3gtaxfhh3#

请看:
https://developer.apple.com/library/ios/documentation/MacOSX/Conceptual/BPInternational/TestingYourInternationalApp/TestingYourInternationalApp.html搜索"测试特定语言和地区"
也许它也可以是创建不同目标的解决方案。每个目标配置了另一种语言

k4aesqcs

k4aesqcs4#

export UDID=202B1006-C2DE-4CC6–8791–6EA4C3782XXX
plutil -replace AppleLocale -string "en_GB" ~/Library/Developer/CoreSimulator/Devices/$UDID/data/Library/Preferences/.GlobalPreferences.plist
xcrun simctl shutdown $UDID
xcrun simctl boot $UDID

相关问题