Visual Studio App Center Test is the next generation of Xamarin Test Cloud! Read the blog post.

Running Tests on iOS

PDF for offline use
Related Articles:

Let us know how you feel about this

Translation Quality


last updated: 2017-07

It is not possible to run UITests on iOS devices in Windows. You can only run UITests for iOS devices on Mac OS X.

If you have an iOS device connected to your computer and it is properly configured, then Xamarin.UITest will attempt to deploy the application to the device and run the tests on it.

There are two ways to run tests on a local device:

  • Through the IDE – Both Visual Studio and Visual Studio for Mac may submit the test run to Test Cloud.
  • Programmatically Declaring the Device – Using the UITest API, a test can explicitly identify a device to run the tests on.

Each of these topics will be discussed in more detail below.


To run tests on an iOS device, the device must be unlocked and configured with a valid development provisioning profile.

Running Tests with the IDE

To run the the tests on a local device, first set the startup project to the iOS project. Next, change the build configuration to Debug > iOS Device:

Selecting the Device

The open the Unit Tests pad in Visual Studio for Mac by selecting View > Pads > Unit Tests.

The first time you want to run test, you will have to Right click on the project in the test pad, and select Run Tests.

Run Test from the context menu

The test will run on the selected device. When the tests have completed, you will be able to see the results in the Test Results pad:

Test Results pad

Programmatically Declaring the Device

If you wish to run your tests at the command line using a script or via CI, then it is necessary to install the IPA on the device. Also, it may be necessary programmatically set the following two pieces of information in your UITest:

  • Build Identifier of the installed application – You can find this in Project Options > Build > iOS Application as the Bundle Identifier: Build Identifier
  • Device Identifier – This is a unique string value that identifies each iOS device and simulator attached to a Mac. It is only required if there is more than one simulator or device. Please see the guide Selecting an iOS Simulator for Local Xamarin.UITests for details on how to obtain the device identifier.

Setting the device identifier is not always necessary. If there are no iOS simulators running but a single iOS device is connected, then UITest will run the tests on the device without have to declare the device identifier. If there are multiple simulators running or more than one device attached, you must specify the device identifier.

The following code snippet demonstrates how to provide these two values to the IApp object:

IApp app = ConfigureApp.iOS

Xamarin Workbook

If it's not already installed, install the Xamarin Workbooks app first. The workbook file should download automatically, but if it doesn't, just click to start the workbook download manually.