Unity
In this document:
- Installation
- Setting Screen Name
- Logging Exceptions
- Troubleshooting
- Identifying Your Users
- Setting Session Attributes
- Remote Logging
Installation
The steps in this section are an example of how to add the TestFairy Unity SDK to your Unity project.
From the TestFairy Unity SDK GitHub page, download the latest version of the
unitypackage
.
In your open Unity project, navigate to Assets --> Import Package --> Custom Package
In the Import Unity Package window, first click All to include the TestFairy SDK in your app. Then click Import.
To use the TestFairy Unity SDK, click
mainCamera
in Hierarchy and in the Inspector clickAdd Component
.Note: you can add the TestFairy script to any game object. TestFairy is a singleton so no harm is done.
Click
Add Component
again, and select aScript
component. Type in the name of the script, for examplemainCameraScript
, and click onCreate and Add
.Edit the newly created CSharp script, add
using TestFairyUnity;
to the import section, and a call toTestFairy.begin();
with your app token. You can find your app token in the Account Settings page.Here is the code, for easy copy-pasting:
using UnityEngine; using System.Collections; using TestFairyUnity; public class mainCameraScript : MonoBehaviour { // Use this for initialization void Start () { TestFairy.begin("PUT YOUR SDK APP TOKEN HERE SEE COMMENT ABOVE"); } ... }
Save, build and run.
Usage
Setting Screen Name
TestFairy can capture screenshots during a recorded session. It attempts to autmatically name a screenshot based on different measures. In order to override this you can invoke setScreenName
, and set your own name for a captured screen. setScreenName
expects a String, so developers are free to label screenshots with any appropriate label. Some developers make use of the level name to set the screenshot, for example:
using UnityEngine;
using System.Collections;
using TestFairyUnity;
using UnityEngine.SceneManagement;
public class cameraScript : MonoBehaviour {
...
void OnLevelWasLoaded(int level) {
TestFairy.setScreenName(Application.loadedLevelName);
}
...
}
Log your exceptions
If you would like to capture exception logs and send them to the TestFairy dashbord use this code example:
private void OnEnable()
{
Application.logMessageReceivedThreaded += HandleLog;
}
private void OnDisable()
{
Application.logMessageReceivedThreaded -= HandleLog;
}
private void HandleLog(string message, string stackTrace, LogType type)
{
TestFairy.log(message);
TestFairy.log(stackTrace);
}
Troubleshooting
If you omit adding the above script, you may encounter the following errors:
ERROR ITMS-90087: "Unsupported Architectures. The executable TestFairy.framework contains unsupported architectures '[x86_64, i386]'
This happens when you export your iOS app for the App store. The App Store only supports apps built for the ARM architecture, however to allow developers to also test in the iOS Simulator, we include the architectures for 64-bit (x86_64) and 32-bit (i386) Intel architectures.
Error: exportArchive: IPA processing failed
Error Domain=IDEFoundationErrorDomain Code=1 "IPA processing failed" UserInfo={NSLocalizedDescription=IPA processing failed}
This happens when you export an Ad hoc version of your iOS app. Most often seen in Unity Cloud build.
Identifying your users
See the SDK Documentation for more information.
Session Attributes
See the SDK Documentation for more information.
Remote Logging
See the SDK Documentation for more information.
Last updated on 2023-03-23