Xcode Simulator Feature

Updated 29 January 2021

Save

XCode Simulator

The simulator allows you to prototype and test builds of your app during the development process. Simulators come as a part of the Xcode tool. It runs on Mac and simulating an iPhone, iPad, Apple TV, or Apple Watch environment. It enables you to simulate apple devices running on current or some legacy OS.

Real Device vs Simulator

There are a few differences between running an application on a device and on the simulator.

If you want all lists of differences then please refer to the official documentation by navigating to Help > Simulator Help in the simulator menu.

Access Simulator from Xcode

There are 2 ways to access Simulator through Xcode.

1. Running Your iOS App

To run an application via a simulator, choose an iOS Simulator from Xcode Schema pop-up menu and click on Run.

2. Launching Simulator Without Running an App

  1. Launch Xcode.
  2. Do one of the following
    • Choose Xcode > Open Developer Tool > Simulator
    • Control-click the Xcode icon in the Dock, and from the shortcut menu, choose Open Developer Tool > Simulator

Organizing Simulators Using Xcode

Xcode provides us a default list of simulators. To view all available simulators follow the below-mentioned steps:

  1. Open Xcode
  2. Select Window > Devices and Simulators menu.
  3.  Select the Simulator Tab.

Now, you will see all the list of simulators that your Xcode includes. It also shows those simulators which you have downloaded earlier.

Creating a new simulator

If you want to create a new simulator then follow the below steps:

  1. Click on the + button at the bottom left
  2. Enter the simulator name
  3. Select the  Device Type
  4. Select the OS version
  5. Click on create.

Uncheck the Show as runtime destination checkbox for the simulator which you have created. This will hide the simulator from the app scheme.

Deleting a Simulator

If you want to delete any particular simulator for your Xcode then follow the below-mentioned steps:

  1. Open Devices & Simulators by following the above-mentioned steps and navigate to the Simulators tab.
  2. Right-click or Control-click on any listed simulator.
  3. Then click on Delete

Downloading Simulator RunTime

If you want to use an older version of the simulator then you can download it from the Components window of Xcode Preference.

Creating Simulator From the Simulator Menu

You can also create a simulator from the simulator menu. To access the simulator menu Open the simulator in your mac via any of the above-mentioned steps. Now follow the below-mentioned steps:

  1. File > New Simulator form the simulator menu
  2. Enter the simulator name
  3. Select the  Device Type
  4. Select the OS version
  5. Click on create.

Now once you create the simulator. You can open the simulator by following the below-mentioned steps:

  1. File > Open Simulator form the simulator menu
  2. Select the run time
  3. Now click on the simulator name which you want to open.

Simulator Features

Dark Mode

You can toggle between Dark and Light Mode appearance by following the below-mentioned steps:

  1. Click on Features Menu of simulator’s menu
  2. Click on Toggle Appearance

Slow Animation

If you want to slow down the animation which you have implemented in your application for testing purpose. Follow the below-mentioned steps:

  1. Click on Debug Menu
  2. Click on Slow Animations

Taking Screenshots

You can capture the current screen of the simulator by following the below-mentioned steps.

  1. Click on File Menu
  2. Click on  Save Screen

Simulating Shake Gesture

  1. Click on Device Menu
  2. Click on Shake

Simulating Memory Warning

iOS sends a warning to the application when the memory usages reach their limit. To create a memory warning follow the below steps:

  1. Click on Debug menu
  2. Click on Simulate Memory Warning

Simulating Location

The simulator provides us an easy way to simulate location. But for this, first, you need to grant location permission to your application.

Follow the below steps to provide a custom location:

  1. Click on Features from Simulator Menu
  2. Select Location > Custom Location
  3. Enter the coordinates
  4. Click OK.

The simulator also provides us the different ways for simulating locations which you can see in the above image.

Useful Shortcuts of Simulator

Managing Simulator with Command Line

Apple provides us simctl to interact with iOS simulators via Command-Line. You can find the binary at /Applications/Xcode.app/Contents/Developer/usr/bin/simctl and you can use it with xcrun command-line tool. This binary is similar to the adb for Android.

To check all available options of simctl enter the below-mentioned command in the terminal.

If you want to see the list of all available simulators enter the below-mentioned command.

To erase a simulator we need to make sure that the simulator is in a shutdown state.

The CRUD operations for the simulator only work on the basis of UUID / Device name therefore you need to enter UUID with each command.

In addition, you can also boot the simulator with the below-mentionded command.

Similarly, you can also generate simulator logs which can help in determining the activity of the simulator by using the below-mentioned command.

Similarly, you can also generate full application info using its bundle ID.

You can also run the simulator in full-screen mode. Use the below-mentioned command to enable this feature :

Capture iOS Simulator video

You can also record a video of the simulator screen using the xcrun command. In addition, to record a video, run the below-mentioned command

Press control + c to stop recording the video. The video file will be stored at the current directory.

Remove unavailable simulators from Xcode

The below-mentioned command will remove those simulators which are not available to the XCode selected version.

 

 

Thank you for reading this article. If you want to read more articles regarding iOS Development click here.

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


2 comments

  • Tash Smith
    • Siddhant
  • Start a Project


      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home