From f59ba2623a5deb46c6f7a83335cb2e74deb6ef9e Mon Sep 17 00:00:00 2001 From: walon Date: Thu, 25 Jan 2024 23:05:28 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E4=BF=AE=E5=A4=8D2019=20build=20iOS?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=20zutil.c=E7=BC=96=E8=AF=91=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AddLil2cppSourceCodeToXcodeproj2019.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Editor/BuildProcessors/AddLil2cppSourceCodeToXcodeproj2019.cs b/Editor/BuildProcessors/AddLil2cppSourceCodeToXcodeproj2019.cs index 034d764..7c957ff 100644 --- a/Editor/BuildProcessors/AddLil2cppSourceCodeToXcodeproj2019.cs +++ b/Editor/BuildProcessors/AddLil2cppSourceCodeToXcodeproj2019.cs @@ -44,6 +44,7 @@ namespace HybridCLR.Editor.BuildProcessors 7. 移除libil2cpp.a 8. Include path add libil2cpp/os/ClassLibraryPAL/brotli/include 9. add external/xxHash + 10. add "#include " to Classes/Prefix.pch */ string pbxprojFile = $"{pathToBuiltProject}/Unity-iPhone.xcodeproj/project.pbxproj"; @@ -62,6 +63,20 @@ namespace HybridCLR.Editor.BuildProcessors "-DIL2CPP_MONO_DEBUGGER_DISABLED", }; ModifyPBXProject(pathToBuiltProject, pbxprojFile, lumpFiles, extraSources, cflags); + AddSystemHeaderToPrefixPch(pathToBuiltProject); + } + + private static void AddSystemHeaderToPrefixPch(string pathToBuiltProject) + { + // 如果不将 stdio.h 添加到 Prefix.pch, zutil.c会有编译错误 + string prefixPchFile = $"{pathToBuiltProject}/Classes/Prefix.pch"; + string fileContent = File.ReadAllText(prefixPchFile, Encoding.UTF8); + if (!fileContent.Contains("stdio.h")) + { + string newFileContent = fileContent + "\n#include \n"; + File.WriteAllText(prefixPchFile, newFileContent, Encoding.UTF8); + UnityEngine.Debug.Log($"append header to {prefixPchFile}"); + } } private static string GetRelativePathFromProj(string path)