GetUnityTestTargetName()
Returns the default test target name.
Read time 1 minuteLast updated 8 days ago
Definition
- Type: Method
- Namespace: UnityEditor.iOS.Xcode
- Assembly: UnityEditor.iOS.Extensions.Xcode
public static string GetUnityTestTargetName()
Returns
Type | Description |
|---|---|
| string | The default test target name. |
Remarks
Use the returned target name to retrieve the GUID of the target via PBXProject.TargetGuidByName.
Note: This function can only be used in Unity-generated projects.
Examples
using UnityEditor;using System.IO;using UnityEditor.Callbacks;using UnityEditor.iOS.Xcode;public class Sample_GetUnityTestTargetName { [PostProcessBuild] public static void OnPostprocessBuild(BuildTarget buildTarget, string pathToBuiltProject) { // Stop processing if build target is not iOS if (buildTarget != BuildTarget.iOS) return; // Initialize PBXProject string projectPath = PBXProject.GetPBXProjectPath(pathToBuiltProject); PBXProject pbxProject = new PBXProject(); pbxProject.ReadFromFile(projectPath); // Get the Test target name string testTargetName = PBXProject.GetUnityTestTargetName(); // Use the name to get Test target GUID string testTargetGuid = pbxProject.TargetGuidByName(testTargetName); // The test target GUID can be later used manipulating the pbxproj file pbxProject.AddFrameworkToProject(testTargetGuid, "Security.framework", false); pbxProject.SetBuildProperty(testTargetGuid, "ENABLE_BITCODE", "NO"); // Apply changes to the pbxproj file pbxProject.WriteToFile(projectPath); }}