如何在 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:26:13  来源:igfitidea点击:

How to run multiple simulators on Xcode 9?

xcodeios-simulator

提问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 & Runon different models but it Quitthe current instance.

我尝试Build & Run使用不同的模型,但它Quit是当前实例。

回答by Kevin Machado

I solved my problem, it's "very simple" :]

我解决了我的问题,它“非常简单”:]

On the simulator, you must choose a new device from Hardware > Devices. The new instance will starts.

在模拟器上,您必须从 中选择一个新设备Hardware > Devices。新实例将启动。

Then, choose your model on Xcode.

然后,在 上选择您的型号Xcode

Here isthe solution.

这是解决方案。

回答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。)

  1. In Xcode, select your first simulation destination platform (Xcode-Product-Destination-select iOS simulator) and run & start a simulation (ie, ?B, ?R).
  2. 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.
  3. Select a differentiOS simulator device.
  4. Run & start the second simulation (ie, ?B, ?R).
  1. 在 Xcode 中,选择您的第一个模拟目标平台(Xcode-Product-Destination-select iOS 模拟器)并运行并启动模拟(即,?B,?R)。
  2. 在 Xcode 中,从 <your_app__name> 执行 Debug-Detach。您的应用程序模拟将继续运行,但 Xcode 将不再与其连接。
  3. 选择不同的iOS 模拟器设备。
  4. 运行并开始第二次模拟(即,?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

I had to detach my running app from the "Debug" -> "Detach from ____" menu if there was already one simulator instance running to get multiple to run at once

如果已经有一个模拟器实例在运行以同时运行多个模拟器,我必须从“调试”->“从____分离”菜单中分离我正在运行的应用程序

image

图片

回答by Harshal Wani

Just select the device name from the model list:

只需从型号列表中选择设备名称:

Select multiple simulators for the same app

为同一个应用程序选择多个模拟器

enter image description here

enter image description here

回答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:

尽管接受的答案将启动另一个模拟器实例,但它实际上并没有启动您的应用程序进行调试——除非我遗漏了一些东西——所以在那之后,请执行以下操作:

  1. Run your app 'manually' in the new simulator instance -- this assumes that it has previously been deployed to this device/iOS combination.
  2. 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'.
  1. 在新的模拟器实例中“手动”运行您的应用程序——这假设它之前已部署到此设备/iOS 组合。
  2. 在 Xcode Debug 菜单中选择“Attach to Process”菜单项,然后从“Likely Targets”列表中选择在步骤 1 中启动的实例。

And you are now running and debugging your app in both simulators.

您现在正在两个模拟器中运行和调试您的应用程序。