TapLoginIOSProcessor.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System.IO;
  2. using TapTap.Common.Editor;
  3. using UnityEditor;
  4. using UnityEditor.Callbacks;
  5. #if UNITY_IOS || UNITY_STANDALONE_OSX
  6. using UnityEditor.iOS.Xcode;
  7. #endif
  8. using UnityEngine;
  9. namespace TapTap.Login.Editor
  10. {
  11. #if UNITY_IOS || UNITY_STANDALONE_OSX
  12. public static class TapLoginIOSProcessor
  13. {
  14. // 添加标签,unity导出工程后自动执行该函数
  15. [PostProcessBuild(103)]
  16. public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
  17. {
  18. var parentFolder = Directory.GetParent(Application.dataPath)?.FullName;
  19. var plistFile = TapFileHelper.RecursionFilterFile(parentFolder + "/Assets/Plugins/", "TDS-Info.plist");
  20. if (!plistFile.Exists)
  21. {
  22. Debug.LogError("TapSDK Can't find TDS-Info.plist in Project/Assets/Plugins/!");
  23. }
  24. if (buildTarget is BuildTarget.iOS)
  25. {
  26. TapCommonCompile.HandlerPlist(Path.GetFullPath(path), plistFile.FullName);
  27. }
  28. else if (buildTarget is BuildTarget.StandaloneOSX)
  29. {
  30. Debug.Log($"path:{path}");
  31. Debug.Log($"path:{Path.GetFullPath(path)}");
  32. Debug.Log($"dir:{Path.GetDirectoryName(path)}");
  33. Debug.Log($"dir:{Path.GetFileName(path)}");
  34. // 获得工程路径
  35. #if UNITY_2020_1_OR_NEWER
  36. var directory = Path.GetDirectoryName(path);
  37. if (string.IsNullOrEmpty(directory))
  38. {
  39. directory = "";
  40. }
  41. var fileName = Path.GetFileName(path);
  42. if (!fileName.EndsWith(".xcodeproj"))
  43. {
  44. fileName += ".xcodeproj";
  45. }
  46. var projPath = Path.Combine(directory, $"{fileName}/project.pbxproj");
  47. #elif UNITY_2019_1_OR_NEWER
  48. var projPath = Path.Combine(path, "project.pbxproj");
  49. #else
  50. #endif
  51. TapCommonCompile.HandlerPlist(Path.GetFullPath(path), plistFile.FullName, true);
  52. }
  53. }
  54. }
  55. #endif
  56. }