如何在 Xcode 9 上运行多个模拟器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44384677/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to run multiple simulators on Xcode 9?
提问by Kevin Machado
According to What's new on Xcode, Xcode 9 allows us to run multiple instance of simulator.
根据Xcode 上的新增内容,Xcode 9 允许我们运行多个模拟器实例。
But what's the way to do this ?
但是有什么方法可以做到这一点?
I tried to Build & Run
on different models but it Quit
the current instance.
我尝试Build & Run
使用不同的模型,但它Quit
是当前实例。
回答by Kevin Machado
回答by Andrew Selby
Xcode allows you to run simulations in parallel (that can communicate with each other as well, if this is part of app functionality), but you cannot run parallel simulations on the same simulated device type (ie, you can't simulate on two iPhone 11 Pros, but your simulations could be, for instance, iPhone 11 Pro Max & iPhone 11 Pro.)
Xcode 允许您并行运行模拟(也可以相互通信,如果这是应用程序功能的一部分),但您不能在相同的模拟设备类型上运行并行模拟(即,您不能在两个 iPhone 上进行模拟) 11 Pros,但您的模拟可能是,例如,iPhone 11 Pro Max 和 iPhone 11 Pro。)
- In Xcode, select your first simulation destination platform (Xcode-Product-Destination-select iOS simulator) and run & start a simulation (ie, ?B, ?R).
- In Xcode, do Debug-Detach from <your_app__name>. Your app simulation will continue to run, but Xcode will no longer be connected to it.
- Select a differentiOS simulator device.
- Run & start the second simulation (ie, ?B, ?R).
- 在 Xcode 中,选择您的第一个模拟目标平台(Xcode-Product-Destination-select iOS 模拟器)并运行并启动模拟(即,?B,?R)。
- 在 Xcode 中,从 <your_app__name> 执行 Debug-Detach。您的应用程序模拟将继续运行,但 Xcode 将不再与其连接。
- 选择不同的iOS 模拟器设备。
- 运行并开始第二次模拟(即,?B,?R)。
I suspect you could detach the second simulation from Xcode also by repeating step 2, and then reattach Xcode to the first instance, for instance if you want the ability to inspect what is happening on either simulated device, but I haven't tried this.
我怀疑您也可以通过重复步骤 2 将第二个模拟与 Xcode 分离,然后将 Xcode 重新附加到第一个实例,例如,如果您希望能够检查任一模拟设备上发生的情况,但我还没有尝试过。
回答by udit gupta
You can run the multiple simulator by using xcodebuild terminal commands like this
您可以使用像这样的 xcodebuild 终端命令来运行多模拟器
xcodebuild test-without-building -xctestrun /PathTo/.xctestrun -sdk iphonesimulator -destination 'platform=iOS Simulator,id=name=iPhone 7,OS=10.3.1' -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.3.1' -destination-timeout 300 -derivedDataPath /pathtoyourderivedata -only-testing:YourTestScheme/YourTestClass/YouTestMethod
xcodebuild test-without-building -xctestrun /PathTo/.xctestrun -sdk iphonesimulator -destination 'platform=iOS Simulator,id=name=iPhone 7,OS=10.3.1' -destination 'platform=iOS Simulator,name=iPhone 7, OS=10.3.1' -destination-timeout 300 -derivedDataPath /pathtoyourderivedata -only-testing:YourTestScheme/YourTestClass/YouTestMethod
The Trick here is to keep adding -destination on the devices you want to run your test on -destination test-without-building - If your project is already build.
这里的技巧是继续在您要在-destination test-without-building 上运行测试的设备上添加-destination - 如果您的项目已经构建。
回答by Ryan Morrison
回答by Christopher King
Although the accepted answer will launch another simulator instance, it doesn't actually launch your app for debugging -- unless I am missing something -- so after that, do the following:
尽管接受的答案将启动另一个模拟器实例,但它实际上并没有启动您的应用程序进行调试——除非我遗漏了一些东西——所以在那之后,请执行以下操作:
- Run your app 'manually' in the new simulator instance -- this assumes that it has previously been deployed to this device/iOS combination.
- In the Xcode Debug menu choose the 'Attach to Process' menu-item and then select the instance launched in step 1 from the list of 'Likely Targets'.
- 在新的模拟器实例中“手动”运行您的应用程序——这假设它之前已部署到此设备/iOS 组合。
- 在 Xcode Debug 菜单中选择“Attach to Process”菜单项,然后从“Likely Targets”列表中选择在步骤 1 中启动的实例。
And you are now running and debugging your app in both simulators.
您现在正在两个模拟器中运行和调试您的应用程序。