- Home /
GetUnityMainTargetGuid() method in 2019.3.x not working in 2019.2.x
Dose anybody have an idea what can be the substitute? Below is the full script for reference.
=====Script==== using UnityEngine; using UnityEditor; using System.Collections; using System.IO;
using UnityEditor.Callbacks; using UnityEditor.iOS.Xcode;
public class TestFairyBuildPostProcessor { [PostProcessBuildAttribute(1)] public static void OnPostprocessBuild(BuildTarget buildTarget, string path) { if (buildTarget == BuildTarget.iOS) { string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
PBXProject proj = new PBXProject(); proj.ReadFromString(File.ReadAllText(projPath)); var mainTarget = proj.GetUnityMainTargetGuid();
proj.AddShellScriptBuildPhase(mainTarget, "Strip unused architectures", "", "sh Frameworks/Plugins/iOS/TestFairy.framework/strip-architectures.sh");
File.WriteAllText(projPath, proj.WriteToString()); } } } =====Script eof====
Answer by ollieblanks · Jun 10, 2020 at 09:17 AM
Pre 2019.3, you will need to use GetUnityTargetName to return the default main target name in the Unity project and then TargetGuidByName to return the GUID of the native target with the given name.
Hope that helps!