[fix] 修复2019 build iOS出现 zutil.c编译错误的bug

main
walon 2024-01-25 23:05:28 +08:00
parent 4b57138935
commit f59ba2623a
1 changed files with 15 additions and 0 deletions

View File

@ -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 <stdio.h>" 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 <stdio.h>\n";
File.WriteAllText(prefixPchFile, newFileContent, Encoding.UTF8);
UnityEngine.Debug.Log($"append header to {prefixPchFile}");
}
}
private static string GetRelativePathFromProj(string path)