Unity Cloud Build: post post method

Problem:

It seems I can not understand the correct signature for the message export method in Unity cloud build post. According to the documentation:

The full name of the public static method that you want to call after the Unity build process is complete (but before Xcode). For example: ClassName.CoolMethod or NameSpace.ClassName.CoolMethod. there is no end bracket, and it cannot have the same name as your pre-export method! This method should take a string parameter that will get the path to the exported Unity player (or Xcode project in case of iOS).

Here is my code:

 public static void OnPostprocessDevBuildIOS(string ExportPath)
    {
        var projPath = ExportPath + "/Unity-iPhone.xcodeproj/project.pbxproj";

        var proj = new PBXProject();
        var nativeTarget =
            proj.TargetGuidByName(PBXProject.GetUnityTargetName());
        var testTarget =
            proj.TargetGuidByName(PBXProject.GetUnityTestTargetName());
        string[] buildTargets = {nativeTarget, testTarget};

        proj.ReadFromString(File.ReadAllText(projPath));
        proj.SetBuildProperty(buildTargets, "ENABLE_BITCODE", "NO");
        File.WriteAllText(projPath, proj.WriteToString());
    }

and here is the error:

enter image description here

I have tried several test method signatures and cannot make anything work. I even tried only a method that outputs the path.

Additional Information:

  • Unity Version: 5.3.1f
  • Unity Cloud Build: 5.3.1f
  • : iOS 8.0 +

, script .

enter image description here

, -, -, , . , . , .

[PostProcessBuild]
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));

        string nativeTarget = proj.TargetGuidByName(PBXProject.GetUnityTargetName());
        string testTarget = proj.TargetGuidByName(PBXProject.GetUnityTestTargetName());
        string[] buildTargets = new string[]{nativeTarget, testTarget};

        proj.SetBuildProperty(buildTargets, "ENABLE_BITCODE", "NO");
        File.WriteAllText(projPath, proj.WriteToString());
    }
}
+4
2

" " . . . Unity 5.4.1p2 Xcode 7.3.

using UnityEngine;
using System.Collections;
using UnityEditor;
using System.IO;
using UnityEditor.Callbacks;
#if UNITY_IOS
using UnityEditor.iOS.Xcode;
#endif

public class Postprocessor : AssetPostprocessor
{   
#if UNITY_IOS
    [PostProcessBuild]
    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));

            string target = proj.TargetGuidByName("Unity-iPhone");

            proj.SetBuildProperty(target, "ENABLE_BITCODE", "false");

            File.WriteAllText(projPath, proj.WriteToString());



            // Add url schema to plist file
            string plistPath = path + "/Info.plist";
            PlistDocument plist = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));

            // Get root
            PlistElementDict rootDict = plist.root;
            rootDict.SetBoolean("UIRequiresFullScreen",true);
            plist.WriteToFile(plistPath);
        }
    }
#endif
}
0

OnPostprocessBuild , - post export method, .

-1

Source: https://habr.com/ru/post/1627350/


All Articles