Testing Unity-built projects targeting the iOS platform is a straight-forward process, and can easily be added to the build-verification pipeline with a few simple steps. This article assumes you have already installed the GameDriver agent into your Unity project, and have at least a basic test running against the Unity editor.


Unity Project Settings

Make sure your project is targeting iOS under the Unity editor > File > Build Settings, and that your project supports the following under Player Settings > Other Settings:


The above Api Compatibility Level is required for the GameDriver agent. You will also need to fill in the iOS Identification Settings specific to iOS deployments. Please refer to the Unity documentation for more information.


Also be sure to select either the Device SDK or the Simulator SDK based on where you plan to test your project. This setting is also found under Player Settings > Other Settings:


Once you have built your project for the iOS platform, it needs to be opened in XCode. From there, you will select either the connected device or Simulator you have configured. For more information on configuring devices and simulators in XCode, refer to the XCode documentation.


Note that some warnings may result from the Unity build which require your attention prior to running on the device or simulator. In many cases, Xcode will resolve these issues automatically simply by clicking the warning and selecting the recommended action. Others will require a configuration change prior to re-building the project in Unity.



NUnit Test Configuration

To launch the iOS Simulator, you will need to use the Launch method in your NUnit test in place of the WaitForGame method which is used to connect to the Unity editor. The Launch method can be used with the simctl command that ships with XCode. The syntax is as follows:

Api.Launch(string filename, [string arguments = ""], [int waitSeconds = 60]);

Using the GameDriver Toolkit for example, we have the following:

Api.Launch(@"/Applications/Xcode.app/Contents/Developer/usr/bin/simctl", @"launch booted com.gamedriver.io.GDIOToolkit");

It can also be helpful to add the path to simctl to your PATH environment variable in macOS. For more information on how to use the simctl command to control iOS Simulators, refer to this article. Note the bundle name shown here is com.gamedriver.io.GDIOToolkit, which is a combination of the Bundle Identifier and Product Name settings in Unity under Build Settings > Player Settings > Player.


Once you have configured your build, your device or simulator in XCode, and your test to run against it, you should be able to execute your test against an iOS Device or Simulator.