Search Unity

GetUnityMainTargetGuid returns null when building Xcode project

Discussion in 'macOS' started by Numa, Sep 10, 2020.

  1. Numa

    Numa

    Joined:
    Oct 7, 2014
    Posts:
    100
    Hi,

    I'm having this issue recently after upgrading to 2020.1 from 2019.4

    GetUnityMainTargetGuid() returns null, but I can see that the PBXProject object has the correct guid if I dig down the data in the debugger.

    Is there a different way to get the GUID?

    Using this code with Unity 2020.1.4f1:
    Code (CSharp):
    1. public static void OnPostProcessBuild(BuildTarget buildTarget, string pathToBuiltProject)
    2. {
    3.     var project = new PBXProject();
    4.     var projectFile = Path.Combine(pathToBuiltProject, "project.pbxproj");
    5.     project.ReadFromFile(projectFile);
    6.  
    7.     var targetGUID = project.GetUnityMainTargetGuid(); // This is null
    8. }
    Thanks!
     
    pandolfini likes this.