using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using System.IO;
using UnityEditor.Build;
using UnityEngine;

public class PostProcessBuild : IPostprocessBuildWithReport
{
    public int callbackOrder => 1;

    public void OnPostprocessBuild(UnityEditor.Build.Reporting.BuildReport report)
    {
        // 检查是否为 iOS 平台构建
        // if (report.summary.platform == BuildTarget.iOS)
        // {
        //     string projectPath = report.summary.outputPath;
        //     string customControllerPath = "Assets/Editor/UnityAppController.mm"; // 自定义文件的路径
        //     string destinationPath = Path.Combine(projectPath, "Classes/UnityAppController.mm");

        //     if (File.Exists(customControllerPath))
        //     {
        //         // 复制文件到 Xcode 项目中
        //         File.Copy(customControllerPath, destinationPath, overwrite: true);
        //         Debug.Log("Custom UnityAppController.mm has been copied to Xcode project.");
        //     }
        //     else
        //     {
        //         Debug.LogError("Custom UnityAppController.mm file not found at " + customControllerPath);
        //     }
        // }
    }
}