How to close simulator after test?

I need to run multiple models in the test. so it will create a lot simulators.how can i close them? I try kill command close simulator, the closed simulator will open in next models simulator.

You could play around with simctl like this person:

https://krypted.com/iphone/managing-the-xcode-simulator-programmatically/

This seems to be the same. when i shutdown iPhone13 and up the iPhone 14, the closed iPhone13 will up by appium

the appium server log:
[DevCon Factory] Requesting connection for device 77685236-5DB2-440D-A3C7-6022D3EC3A96 on local port 8100
[debug] [DevCon Factory] Cached connections count: 1
[DevCon Factory] Found cached connections on port #8100: [“F06F9153-A7A7-42DE-8D66-60BCBAFCE875:8100”]
[DevCon Factory] Successfully requested the connection for 77685236-5DB2-440D-A3C7-6022D3EC3A96:8100

it seems appium not release connection

Did you change the device name in capabilities?

Hi man, I may have your answer, I had a similar issue.
go to Simulator preferences -> disable the option When Simulator starts boot the most recently used simulator

Additionally, I run my tests using Jenkins, so after each test I run:
xcrun simctl shutdown $DEVICE_NAME
when $DEVICE_NAME is the name I gave the device when I created it in iOS Simulator -> file -> new simulator.
good luck.

I’ve also had better luck when naming simulators something unique. iPhone_for_t0 is a much better name than ‘iPhone 8’.

1 Like

the lifetime is default like this, I have used simctl command to close simulators.Howerver, it is not ok.
image

One device name is iPhone 13, the other name is iPhone 14

it is a bit funny but make sure you put quotation marks when you use the simctl command. like “iPhone 13” and “iPhone 14” otherwise he will read them the same…

you can also try to update your Xcode including the Simulator app and see if something changes.