How to fix error: Could not reset simulator. Leaving as is

Hi there,

after running a simple test successful, I receive the following error:

error: Could not reset simulator. Leaving as is. Error: Command 'xcrun simctl erase 2C70F4F9-B59E-421E-ACD6-DADF96A09B8D' exited with code 159

My setup is:

  • Mac OS El Capitan
  • Appium GUI 1.4.13
  • xCode 7.2.1
  • Eclipse Mars.2
  • Appium Java Client 3.4.1
  • Java Selenium binding 2.53.0

The error seems to be a bit similar to this post. But restarting the machine/Appium GUI does not help.

The error is reproducible. I receive it each time running any test.
Note that the tests end themselves successful!

Has anyone an idea how to solve this issue?

Thanks in advance :).

Easiest solution would be to delete that simulator and recreate. Simulators are cheap.

Hi,

ehm how do I do that? I’m quite new to Appium and Mac, please give me a more detailed answer :).

The error message is shown up automatically in the Appium GUI’s log window.

Which settings have I to change that the simulator gets deleted after a test?

Greets.

A Google search is a great place to find information like this. Here’s a Stack Overflow answer that should get you going. If you name the new Simulator the same as the old (and use the same version of iOS) then there is nothing you’d need to change from Appium side:

If you name the new Simulator the same as the old (and use the same version of iOS) then there is nothing you’d need to change from Appium side

But this is exactly what I am doing. I always use the same device name and platform version in the Appium GUI.

Thanks for taking that out of context. You have a corrupt Simulator. Ignoring that dooms you to failure.

Ehm. So there is no possibility to solve this issue?

I tried to list the available simulators by typing xcrun simctl list in the terminal. I received this log:

== Devices ==
– iOS 9.2 –
iPhone 4s (FB7D8258-0F15-4E63-8D5B-1D52DA5BF2ED) (Shutdown)
iPhone 5 (391CB34C-97B3-4BA8-9221-DAB5599A334A) (Shutdown)
iPhone 5s (3A13D68A-4DCC-4FBA-9D71-E5E02349A86B) (Shutdown)
iPhone 6 (2C70F4F9-B59E-421E-ACD6-DADF96A09B8D) (Shutdown)
iPhone 6 Plus (BFD95DEA-5915-46D9-9B9A-A01A5E9EF040) (Shutdown)
iPhone 6s (8871907D-E88D-4E10-9621-8854B33E7A2C) (Shutdown)
iPhone 6s Plus (720218BF-B4EF-4290-BA21-C01E2DD4FBD1) (Shutdown)
iPad 2 (2DB9D0A1-3D4D-4CFE-8397-F088168A56F3) (Shutdown)
iPad Retina (A096C3E2-DDDC-4675-BEAE-F1C69C6AA83A) (Shutdown)
iPad Air (0BFBF732-51D7-40CC-B12A-F9799ADDB733) (Shutdown)
iPad Air 2 (8DB43FAF-7DC9-47BB-9C58-1514A88F1232) (Shutdown)
iPad Pro (83238430-FA16-45CF-B8AF-9FEC545793FA) (Shutdown)

Then I tried to delete the simulator manually by typing xcrun simctl erase 2C70F4F9-B59E-421E-ACD6-DADF96A09B8D.

But also this had no effects on the simulator list…

Greets.

You are trying to use the command line. Why not query the tool to see what the options are like this:

xcrun simctl
Usage: simctl [--noxpc] [--set <set path>] <subcommand> ... | help [subcommand]
Command line utility to control the Simulator

For subcommands that require a <device> argument, you may specify a device UDID
or the special "booted" string which will cause simctl to pick a booted device.
If multiple devices are booted when the "booted" device is selected, simctl
will choose one of them.

Subcommands:
	create              Create a new device.
	delete              Delete a device or all unavailable devices.
	pair                Create a new watch / phone pair.
	unpair              Unpair a watch and phone phone.
	erase               Erase a device's contents and settings.
	boot                Boot a device.
	shutdown            Shutdown a device.
	rename              Rename a device.
	getenv              Print an environment variable from a running device.
	openurl             Open a URL in a device.
	addphoto            Add photos to the photo library of a device.
	addvideo            Add videos to the photo library of a device.
	install             Install an app on a device.
	uninstall           Uninstall an app from a device.
	get_app_container   Print the path of the intsalled app's container
	launch              Launch an application by identifier on a device.
	spawn               Spawn a process on a device.
	list                List available devices, device types, runtimes, or device pairs.
	icloud_sync         Trigger iCloud sync on a device.
	help                Prints the usage for a given subcommand.

If you read the description for ‘erase’ you’ll probably notice that it doesn’t do what you are trying to do. Maybe there is a command on that list that you could find that will do what you want.

how would one delete and create a simulator. im using groovy/java code in my framework is there a way i can code that into my framework before each test delete sim then create one.

Programmatically you can use the above tool from a system call. Alternatively you could write a shell script and call that through a system call. It really depends on your preference and setup.

For example in our Jenkins instance we use a shell script to erase and create simulators, but for a local run I would probably just use a system call from the framework.

Here is a somewhat dated but useful read on simctl:

There are plenty of others just a google search away…