如何从命令行以特定语言启动iOS Simulator?

Mic*_*ala 4 xcode xcodebuild instruments ios

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

instruments -w <device>
Run Code Online (Sandbox Code Playgroud)

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

-AppleLanguages -AppleLocale
Run Code Online (Sandbox Code Playgroud)

但有一些警告:

Instruments Usage Error : Specified target process is invalid: -AppleLanguage
Run Code Online (Sandbox Code Playgroud)

谢谢!

Mic*_*ala 7

使用特定语言启动的唯一方法iOS Simulator是更改​​其.GlobalPreferences.plist文件的内容。使用xcrun工具将不起作用,因为它会将参数传递给启动的应用程序,并且不会更改模拟器本身的语言。操作.GlobalPreferences.plist非常困难,因为它是一个二进制plist文件,因此您不能将其修改为“正常” xml。更改其内容的最简单方法就是编写简单的代码Xcode Command Line Tool application,FoundationSDK拥有修改二进制文件所需的所有工具plists。


Har*_*dim 5

要运行您的应用必须安装和定位(如果没有,将打开默认语言)

使用此命令以某种语言运行您的应用程序

xcrun simctl launch <deviceid> <appid> -AppleLanguages "(pt-BR)"
Run Code Online (Sandbox Code Playgroud)

样品:

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)"
Run Code Online (Sandbox Code Playgroud)