기술 자료

Unity Engine

Unity Engine

GetUnityTestTargetName()

Returns the default test target name.
읽는 시간 1분최근 업데이트: 한 달 전

Definition

public static string GetUnityTestTargetName()

Returns

Type

Description

stringThe 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); }}