Become an iOS Simulator Master-Part 1

Batikan Sosun
Sahibinden Technology
4 min readMar 21, 2022

--

Extend your skills with the iOS Simulator that makes you more productive. Just be sure that you follow the way which creates efficiency during the development.

Photo by Joan Gamell on Unsplash

iOS Simulators are mac apps that simulate your iOS, iPadOS, tvOS, or watchOS apps directly on your Mac. Also, you don’t need to have a physical device to develop any apps for these platforms. You can exclude exceptional circumstances.

While you are developing and testing your apps on the Simulator you can use many features. The simulator’s friendly graphical interface can speed things up and simulate very well a lot of features of real devices.

However, using the terminal is also a great way to speed things up and the only way to create useful scripts for Continuous Integration & Continuous Delivery servers.

xcrun command that comes with Xcode CLI has a set of command-line tools. One of them is Simctl we are using it for interaction with Xcode Simulator.

Simulator Control in short form Simctl provides a lot of commands to more using Simulator advanced features. If you are also developing Android apps you can think that of ADB for Android.

Simctl comes bundled with Xcode and that located here. You can check in this path:

/Applications/Xcode.app/Contents/Developer/usr/bin/simctl

This command-line utility works with xcrun. After all of these, I will try to explain some subcommands of Simctl and another point is what we can do with Simctl through these.

Using Simctl, we can perform a lot of tasks that are including how you manage, create, rename, erase, upgrade, boot, and shutdown simulators.

Before moving into all commands, you can list all options by running the below subcommand which is named help.

And then, that will give you a list that looks like the following view.

As you see, the usage of Simctl requires a set of subcommands. Simctl usage format should be like that:

If wanting to know more about a specific subcommand, you can use just the below command.

As an example, I used the ‘create’ subcommand. This will give you a little information that how you can create a device through the terminal.

output:

Simctl Subcommands

Let’s deep dive the all of these subcommands.

List Simulators

To list available devices, device types, runtimes, or device pairs you can run the following command. Don’t forget that each subcommand has attributes(something like that :) ) example: to print as JSON use -j
If you forget them use the help command to access them.

output:

Mine is fairly more. I use often simulators than physical devices.

One more thing that is related to the list, the following command will list the simulator which is booted.

This output will give you the simulator name, UUID, and booted information.

Create Simulator

As you can create a simulator from Simulator Graphic Interface(GUI) you can create a simulator from the terminal.

After running this command, you will get a UUID, which will let you execute all types of operations involving this newly created simulator.

Clone simulator

I love this command. This one allows you to easily copy one simulator to another one.

Upgrade simulator

This command performs a task that upgrades a device to a newer runtime

Delete Simulator

If you want to delete a simulator through the terminal you can. Delete subcommand allow you to delete specified devices, unavailable devices, or all devices.

Pair Devices

The pair command creates a new watch and phone pair. Also, you check which devices are paired in the list command output.

When you pair two you will get a UUID. You can use it for the next command that is unpair.

if you are wondering how I created the watch that is named mine-watch-simulator. That was the same with creating an iPhone simulator. Follow the below command.

Unpair Devices

As you can see, unpair is the opposite of pair. This allows you to unpair a watch and phone pair.

pair_activate Devices

Set a given pair as active.

Erase Simulator

Erase a device’s contents and settings. This command should not be confused with the Delete command.

Boot Simulator

Now, you can boot a simulator or a simulator pair by the following command. Boot command requires a simulator name or a UUID.
Also, you can boot a pair simulator. In my instance, I used a UUID which is I created before when I pair a watch and an iPhone.

Shutdown Simulator

By using the UUID you can perform to shutdown a simulator you would run the following command:

I need to take a breath from now on. I am going to end Part 1 of the article here. I think I explained about 11 subcommands of Simctl. The next part will be much more important due to Simctl core commands. When I finished the next one I will be posting here it.

After a couple of days, I finally completed the second part of the article. The second part is here:

Let’s connect on Twitter.

--

--

Batikan Sosun
Sahibinden Technology

Tweeting tips and tricks about #swift #xcode #apple Twitter @batikansosun Weekly Swift Blogging