JD2022-TU1/main/phone_apps/Extern/XUPorter/XCodePostProcess.cs

45 lines
1.2 KiB
C#

using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.XCodeEditor;
#endif
using System.IO;
public static class XCodePostProcess
{
#if UNITY_EDITOR
[PostProcessBuild(999)]
public static void OnPostProcessBuild( BuildTarget target, string pathToBuiltProject )
{
if (target != BuildTarget.iPhone) {
Debug.LogWarning("Target is not iPhone. XCodePostProcess will not run");
return;
}
// Create a new project object from build target
XCProject project = new XCProject( pathToBuiltProject );
// Find and run through all projmods files to patch the project.
// Please pay attention that ALL projmods files in your project folder will be excuted!
string[] files = Directory.GetFiles( Application.dataPath, "*.projmods", SearchOption.AllDirectories );
foreach( string file in files ) {
UnityEngine.Debug.Log("ProjMod File: "+file);
project.ApplyMod( file );
}
//TODO implement generic settings as a module option
project.overwriteBuildSetting("CODE_SIGN_IDENTITY[sdk=iphoneos*]", "iPhone Distribution", "Release");
// Finally save the xcode project
project.Save();
}
#endif
public static void Log(string message)
{
UnityEngine.Debug.Log("PostProcess: "+message);
}
}