iOS Build Environment Help Center

Delete

(Leave this as-is, it’s a trap!)

To delete this post you must be either the original author or a designated moderator.
The content of the post will be removed but the name and date will remain.

  • The post will be removed completely from the thread, rather than blanked
  • Only posts on the last page of the thread can be removed completely (so as to not break permalinks)

RE[20]: 'pch-cpp.hpp' file not found

redclad

Hello, I am currently facing the same issue with Unity 2023.1.9f1. Interestingly, when the il2cpp compiler calls clang.exe before the error, we can see that there is one folder included as absolute path and several as relative paths.
Here are the ones I got.
-I"."
-I"C:/Unity/ProjectAAA/iOS/Il2CppOutputProject/Source/il2cppOutput"
-I"Il2CppOutputProject/IL2CPP/libil2cpp/pch"
-I"Il2CppOutputProject/IL2CPP/libil2cpp"
-I"Il2CppOutputProject/IL2CPP/external/baselib/Include"
-I"Il2CppOutputProject/IL2CPP/libil2cpp/os/ClassLibraryPAL/brotli/include"
-I"Il2CppOutputProject/IL2CPP/external/baselib/Platforms/IOS/Include"

So I decided to copy the content of the "Il2CppOutputProject/IL2CPP/libil2cpp/pch" folder to the "Il2CppOutputProject/Source/il2cppOutput" folder which is included as absolute path and that "fixed" the _fatal error: 'pch-cpp.hpp' file not found_
Unfortunately, it was replaced by another error for another file not found.
So I played around and tried to copy all the content from the folders included with relative paths to the one with absolute path. Unfortunately, by doing so, I also move many unnecessary files (such as the ones devoted to other OS) that get compiled leading to even more missing dependencies.
Thus, it always gives me new missing files error but I think that if we place only the necessary files in the right folder, it should be possible to find a temporary fix.

If someone manages to pinpoint what files should be copied and what files shouldn't, please keep us updated.

Ultimately, if Unity devs need to find a solution, the il2cpp compiler creates a il2cpp.cmd file in the "build\Release-iphoneos\GameAssembly" folder. We can see there the relative path
--custom-il2-cpp-root="Il2CppOutputProject/IL2CPP"
I believe, this is what they should change to an absolute path when generating the il2cpp.cmd file that is likely used when calling clang.exe.

I hope it can help fix the problem for some people.

:: @redclad added on 09 Sep ’23 · 16:26

Well, the good news is that I found a workaround to fix this problem by modifying one file in the Xcode project folder created by Unity: Unity-iPhone.xcodeproj/project.pbxproj
The bad news is that it can be tedious.

I had to replace
$(PROJECT_DIR)
$(SRCROOT)
$PROJECT_DIR
Il2CppOutputProject
Libraries
with their full path when meaningful (=> manually check).

Good luck to find which instances need to be changed or not. I had to go by trial and error until the il2cpp build completed successfully.
Most of the paths are broken and not defined or read properly. If someone could find in what file all these path values are defined and supposedly read from, it would be more convenient to fix the problem there.

There are further problems when building the dependency project UnityFramework (after the il2cpp built) with
$(BUILT_PRODUCTS_DIR)
$CONFIGURATION_BUILD_DIR
etc.

Now, I need to fix the next problem in line for me: missing symbols error.

Moderators: Pierre-Marie Baty