From 97dae7fed2f66fe4624902c1113b8e38e7b73d7a Mon Sep 17 00:00:00 2001 From: walon Date: Tue, 14 May 2024 21:59:56 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E4=BF=AE=E5=A4=8D=E5=BD=93Append=20xco?= =?UTF-8?q?de=E9=A1=B9=E7=9B=AE=E5=88=B0=E7=8E=B0=E5=AD=98=E7=9A=84xcode?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=97=B6=EF=BC=8C=E7=AC=AC1=E6=AC=A1?= =?UTF-8?q?=E4=BC=9A=E5=AF=BC=E8=87=B4'Run=20Script'=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E8=A2=AB=E9=87=8D=E5=A4=8D=E8=BF=BD=E5=8A=A0=EF=BC=8C=E4=BB=8E?= =?UTF-8?q?=E7=AC=AC2=E6=AC=A1=E8=B5=B7=E5=B0=86=E4=BC=9A=E6=89=BE?= =?UTF-8?q?=E4=B8=8D=E5=88=B0--external-lib-il2-cpp=E8=80=8C=E6=89=93?= =?UTF-8?q?=E5=8D=B0=E9=94=99=E8=AF=AF=E6=97=A5=E5=BF=97=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Lil2cppSourceCodeToXcodeproj2022OrNewer.cs | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Editor/BuildProcessors/AddLil2cppSourceCodeToXcodeproj2022OrNewer.cs b/Editor/BuildProcessors/AddLil2cppSourceCodeToXcodeproj2022OrNewer.cs index b82c1ca..86d5673 100644 --- a/Editor/BuildProcessors/AddLil2cppSourceCodeToXcodeproj2022OrNewer.cs +++ b/Editor/BuildProcessors/AddLil2cppSourceCodeToXcodeproj2022OrNewer.cs @@ -37,15 +37,25 @@ namespace HybridCLR.Editor.BuildProcessors { string pbxprojContent = File.ReadAllText(pbxprojFile, Encoding.UTF8); string removeBuildOption = @"--external-lib-il2-cpp=\""$PROJECT_DIR/Libraries/libil2cpp.a\"""; - if (!pbxprojContent.Contains(removeBuildOption)) + if (pbxprojContent.Contains(removeBuildOption)) { - //throw new BuildFailedException("modified project.pbxproj fail"); - Debug.LogError("[AddLil2cppSourceCodeToXcodeproj] modified project.pbxproj fail"); - return; + pbxprojContent = pbxprojContent.Replace(removeBuildOption, ""); + Debug.Log($"[AddLil2cppSourceCodeToXcodeproj] remove il2cpp build option '{removeBuildOption}' from file '{pbxprojFile}'"); } - pbxprojContent = pbxprojContent.Replace(removeBuildOption, ""); + else + { + Debug.LogWarning($"[AddLil2cppSourceCodeToXcodeproj] project.pbxproj remove building option:'{removeBuildOption}' fail. This may occur when 'Append' to existing xcode project in building"); + } + + int strShellScriptIndex1 = pbxprojContent.IndexOf("/* ShellScript */,"); + int strShellScriptIndex2 = pbxprojContent.IndexOf("/* ShellScript */,", strShellScriptIndex1 + 10); + if (strShellScriptIndex2 >= 0) + { + pbxprojContent = pbxprojContent.Remove(strShellScriptIndex1, strShellScriptIndex2 - strShellScriptIndex1); + Debug.LogWarning($"[AddLil2cppSourceCodeToXcodeproj] remove duplicated '/* ShellScript */' from file '{pbxprojFile}'"); + } + File.WriteAllText(pbxprojFile, pbxprojContent, Encoding.UTF8); - Debug.Log($"[AddLil2cppSourceCodeToXcodeproj] remove il2cpp build option '{removeBuildOption}' from file '{pbxprojFile}'"); } private static void CopyLibil2cppToXcodeProj(string pathToBuiltProject)