27 lines
832 B
C#
27 lines
832 B
C#
#if UNITY_IOS
|
|
using UnityEditor;
|
|
using UnityEditor.Callbacks;
|
|
using System.IO;
|
|
using System.Text.RegularExpressions;
|
|
|
|
public class iOSFixDuplicateShellScript
|
|
{
|
|
[PostProcessBuild]
|
|
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
|
|
{
|
|
if (target != BuildTarget.iOS) return;
|
|
|
|
string projPath = Path.Combine(pathToBuiltProject, "Unity-iPhone.xcodeproj/project.pbxproj");
|
|
if (!File.Exists(projPath)) return;
|
|
|
|
string content = File.ReadAllText(projPath);
|
|
|
|
// 匹配 GameAssembly target 的 buildPhases 中连续两个相同的 ShellScript
|
|
string pattern = @"(\t+([A-F0-9]+) /\* ShellScript \*/,)\n\t+\2 /\* ShellScript \*,/";
|
|
content = Regex.Replace(content, pattern, "$1");
|
|
|
|
File.WriteAllText(projPath, content);
|
|
}
|
|
}
|
|
#endif
|