Testing iOS apps built with Unity

Learn how to test on iOS devices and simulators using GameDriver

Testing Unity-built projects targeting the iOS platform is a straightforward 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. You will also need to fill in the iOS Identification Settings specific to iOS deployments. Please refer to the Unity documentation for more information.

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 the 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 requires 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 static ApiClient.Launch method can be used with the simctl command that ships with XCode. The syntax is as follows:

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

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

ApiClient.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.

Connecting to the device

Once you have built the app in XCode, you will need to connect to the device from the test using one of two methods:

  • Directly using the IP address of the device
  • Over USB using the iProxy command

To obtain the IP address of the device, access the Settings > Wi-Fi > (I) dialog:

To use the iProxy command, download and install the libimobiledevice library and run the command:

iproxy -l 19734:19734

This will forward traffic to the locally connected device on port 19734.