Setting up an iOS Simulator

Modified on Mon, 15 Apr 2024 at 02:43 PM

Step 1: Verify Xcode and Mac Operating System Versions

Xcode is an integrated development environment (IDE) designed by Apple for macOS. It provides a comprehensive set of tools and resources for software development.
Make sure that you have the latest and compatible version of Xcode installed on your Mac.
Upon installation, Xcode must be configured. Run the following the command: 

Xcode-select  --Install

In this case, the macOS and Xcode versions are:

  • MacOS: Sonoma 14.2
  • Xcode: 15:0:1

Tip: You can download the latest MacOS version from your App Store depending on your processor.
By default, Xcode will be pre-installed. Make sure to download the latest version from App store using your Apple credentials. If you are unaware of the Mac OS compatibility, then you can search for Xcode in the App store and look for the details in the what's new column.



Before installing Appium, you need to set up the Appium. To set up the  Appium, you need to install HomeBrew, Cathrage and Java. Follow the procedure described in the article - Setup and Configure Appium on Mac operating system for iOS devices.


Step 2: Install Appium

To install Appium globally on your system, run the following command in the command line.

npm install -g appium@latest
Tip: If you wish to install a specific version, you can run the npm install -g appium@ <version> command in the command line.


2.1: To verify Appium installation

Upon installing Appium, you can access it from the command line by running the following command:

appium -v

The output verifies whether Appium is installed successfully and displays the appropriate version.


To verify the path, run the following command: 

Where Appium 

Step 3: Diagnose and Resolve Common Node and iOS Configuration Issues

Perform the following to diagnose and address common configuration issues with Appium.

3.1: Install Appium Doctor

Begin by installing Appium doctor by running the following command in the command-line prompt:

npm install appium-doctor -g

Step 4: Install Appium Driver

Since version 2.0, all drivers have been isolated from the Appium server app and can be managed independently using the Appium driver command-line interface.

4.1: Install XCUITest Driver
XCUITest is the official UI testing framework provided by Apple for iOS. Appium uses the XCUITest Driver to communicate with and control your iOS app, allowing you to perform automated actions, such as tapping buttons, entering text, and verifying UI elements. This driver is specifically designed for iOS app automation.

To install the XCUITest driver, run the following command:

appium driver install xcuitest


Step 5: Install Appium Inspector

 Perform the following to install Appium Inspector for Appium 2.1.

5.1: Download and Install Appium Inspector

To download and install the latest version of Appium Inspector .dmg file, click here.


Once you download the file and double-click the DMG file to mount it to your Mac. You can now access the file through your desktop or Finder sidebar. After you mount the DMG file to your device, drag it to the Applications folder on your Mac. The file then copies itself into the folder with a lag time. When the file is fully moved into the applications folder, you can open it from the 'Spotlight' or 'Launchpad' program shortcuts.


5.2: Launch Appium Inspector

Open the application from your Mac OS Launchpad.


If the app fails to launch, try the following:

  • Go to Mac OS Settings > Privacy & Security > Open Anyway.


5.3 Adding the required capabilities


In Appium, the required capabilities are provided in the Appium Inspector to specify the details and configuration of the mobile device or simulator that the Appium server should interact with during test automation. These capabilities include information such as the device name, platform name, platform version, app package, app activity, and other relevant settings.

Perform the following to add the required capabilities: 

  1. Enter the appropriate Remote Path to view the desired capabilities.
  2. You can also view the capabilities in the JSON representation in the right pane.
    The JSON representation of capabilities in Appium provides a standardized, structured, and readable way to convey the configuration details needed for automated testing.


Step 6: Verify Xcode Configurations

Make sure you have installed Xcode and Xcode command-line tools. Follow the procedure described in Setup and Configure Appium on Mac operating system for iOS devices. 

6.1: Ensure That You Are Logged in with an Apple Account

Before proceeding with the Xcode configurations, make sure you are logged in with your Apple Developer account. To check, follow these steps:

  • Navigate to Xcode via applications
  • In the menu bar, go to Xcode > Preferences.
  • Under the “Accounts” tab, ensure that your Apple ID is listed, and it shows “Personal Team.”

This is a crucial step for code-signing your apps and WebDriverAgent.


Step 6.2 Configuring Web Driver Agent in the Simulator


  1. For installing  Web driver agent, refer to Install Web Driver Agent article.
  2. To verify the configuration of the Web driver agent, run the following command in the terminal:
    git clone https://github.com/appium/WebDriverAgent.git
  3. Change the required directory by running:
    cd WebDriverAgent
  4. Build and Run WebDriverAgent
    This command is used to build and run tests for the WebDriverAgent project in Xcode without performing a full build of the entire project. It is a common practice in automated testing workflows to speed up the testing process by skipping unnecessary build steps.
    xcodebuild build-for-testing test-without-building -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=56BF9C2F-DC97-401A-A1AA-F295FA8296A9' -allowProvisioningUpdates
    
    


Step 6.3 Verifying the UDID number

In this command, the unique identifier 56BF9C2F-DC97-401A-A1AA-F295FA8296A9 corresponds to a specific simulator or device., also called UDID number.

To locate the UDID number, navigate to Xcode and on the Windows menu > select Devices and Simulators


Step 6.4 Confirm xcrun simctl Configuration

xcrun simctl is a command-line utility for interacting with the iOS Simulator.

In this step,  xcrun simctl configuration is verified. This is an essential component for managing simulator runtimes and is crucial for the successful execution of Appium.


  1. Navigate to your terminal.
  2. Run the following command:
xcrun simctl

This command is used to manage the simulator and must display information about its usage. The following output is displayed:

usage: simctl [--set <path>] [--profiles <path>] <subcommand> ...
simctl help [subcommand]
Command line utility to control the Simulator


Step7: Prepare your iPhone as a simulator


On your iPhone, go to Settings > enable Developer Mode > Privacy & Security. Restart the device if required.



This ensures that your iPhone is recognized by Xcode and is ready for development and testing.





Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article