iOS Build Environment Help Center

'pch-cpp.hpp' file not found

append delete Maximilian Schmidt

Windows: 22H2 19045.2728
Builder: 3.55.1
IOS SDK 16.2
Unity Version 2023.1.0b1
see: https://cloud.taking.pictures/s/64w3idJ93MXD4Kf

Dear Mr. Baty,
i tried to build a scene of my ARDK unity project by following your tutorial. This single scene does not use ARDK functionality. Other scenes in this project do.
In the beginning i was on unity 2022.2.8f1. Shortly after i encountered this problem:

https://www.pmbaty.com/iosbuildenv/help/thread.php?path=Problem%20solving/&file=libtool-exe-command-line-can-get-above-the-windows-8k-limit

So i upgraded Unity to 2023.1.0b1 (even the latest alpha does behave the same) and the problem was gone. Now i face this error no matter what settings i choose:
##### Output
C:/IOS Project/Il2CppOutputProject/Source/il2cppOutput/UnityEngine.UIElementsModule5.cpp:1:13: fatal error: 'pch-cpp.hpp' file not found
<U+FEFF>#include "pch-cpp.hpp"

While testing i also ran into:

https://www.pmbaty.com/iosbuildenv/help/thread.php?path=Problem%20solving/&file=ld-framework-not-found-null-error-while-trying-to-build-ardk-lightship-example-scene

but i cannot reproduce this error anymore.

So whats left seems to bee this "pch-cpp.hpp" error as you can see in the log its omnipresent. I managed to find one post which might have something to do with the issue iam facing? -> https://developer.apple.com/forums/thread/22060

So while iam writing this start a search for this "missing" file in parallel and as you can see on the screenshot, the file is there, the path is short. What am i missing?! So i thought sometimes spaces in paths are a problem, but even after replacing "IOS Project" with "C:/IOS_PROJECT/"the error stays the same. i have no clue.

Hopefully the provided information is helpful. i could also upload a unity package with a basic ARDK scene or whatever if it helps. I'd very much appreciate your help on this.
kind regards,

Maximilian Schmidt

Reply RSS

Replies

append delete #1. Pierre-Marie Baty

Hello

That's an interesting one. I suspect you've nailed a bug in my symlink emulation code. The Unicode byte ordering prefix (U+FEFF) in the UnityEngine.UIElementsModule5.cpp leads me to this hypothesis. You might be able to work it around by inserting a newline at the very top of the affected .cpp files, so that the incriminated #include is immediately preceded by a '\n', but that wouldn't be the cleanest way of fixing it.

Could you please send me a Xcode project (not a Unity package, but the Xcode project created by your editor) that exhibits this error at build time, so that I reproduce the problem ? Thanks in advance.

append delete #2. Maximilian Schmidt

Good evening!
thanks for your fast reply, glad its something new even to you^^
I will try the fix you proposed ASAP.
I also just uploaded the entire IOS_PROJECT Folder in my nextcloud share and sent you login infos via email.

thank you very much :)

append delete #3. Maximilian Schmidt

Good evening again, so just to confirm i understood you correctly.

i ran a powershell script which does what it is supposed to do, if i understood you correctly:

# Define the folder to search
$folder = "C:/IOS_PROJECT_GPT/Il2CppOutputProject/Source/il2cppOutput/"

# Get all C++ files in the folder and its subfolders
$cppFiles = Get-ChildItem $folder -Recurse -Filter "*.cpp"

# Loop through each C++ file and add "\n" to the beginning
foreach ($file in $cppFiles) {
# Read the file contents
$content = Get-Content $file.FullName

# Add "\n" to the beginning of the file contents
$content = "\n" + $content

# Write the modified file contents back to the file
Set-Content $file.FullName $content
}

which results in this for the example file: "UnityEngine.TextCoreTextEngineModule1.cpp"

\n#include "pch-cpp.hpp" struct Dictionary_2_tC20B3D6AE4370C892734F670EF4D1FB9CE91F371; .....

This is how you meant it to be, right? this still outputs:

C:/IOS_PROJECT/Il2CppOutputProject/Source/il2cppOutput/UnityEngine.TextCoreTextEngineModule1.cpp:1:13: fatal error: 'pch-cpp.hpp' file not found
<U+FEFF>#include "pch-cpp.hpp"

thanks again :)

append delete #4. Maximilian Schmidt

omg i just realised, that just copying the unity xcode folder does not wok as it still refers to the old paths as we can see in the log -_- Ok nevermind , just ignore my last comment. i try again with a fresh build^^

append delete #5. Maximilian Schmidt

Good morning,

so i tried again and the "pch-cpp.hpp not found" error seems to persist for me.
i have also uploaded the unity project after applying the powershell "\n" script so you can see it for yourself in the log or by executing the builder on it again. -> "IOS_PROJECT_NEWLINE"

i also corrected my script making "\n" -> "`n" to get a real linebreak which is visible in the files now. Sadly it does not change the error output for me.

thank you!

append delete #6. Pierre-Marie Baty

Ok so that was a wrong guess. I’ll look at your project today.

:: @Pierre-Marie Baty added on 23 Mar ’23 · 12:43

*edit* Okay, the problem is nailed down. The compiler error happens not in the builder-driven step, but in Unity's IL2CPP compiler driver-driven step. An include path is missing in the Unity-constructed compiler invokation command line. The interesting bit here is that the missing include path appears in the Xcode project file in the HEADER_SEARCH_PATHS array of variables only, which is *not* passed to the Unity IL2CPP compiler driver. I am forced to deduce that the Unity IL2CPP compiler driver (which is from the builder's point of view a kind of "black box") either has platform-dependent, hardcoded include paths, or parses the Xcode project file on its own when it's running on macOS and doesn't do it when it's running on Windows. I'll add these paths explicitly in the build script and see if it works.

:: @Pierre-Marie Baty added on 23 Mar ’23 · 13:42

*edit 2* Alright, it is proven that the il2cpp compiler driver passes hardcoded include paths to the Clang compiler. These paths are relative to the Xcode project root. The fact that the compiler fails to find an include file at the right relative path can only mean that the il2cpp compiler driver fails to set the current working directory properly when starting clang on Windows.

append delete #7. Pierre-Marie Baty

Bottom-line : it seems to be a Unity il2cpp compiler driver bug that is specific to the Windows platform. I'll drop a note to my contact at Unity to notify them of the issue. Hopefully they'll provide a fix soon.

append delete #8. Maximilian Schmidt

Hello Mr. Baty!

Thank you very much for your efforts, as well for your email reply!
I very much appreciate your engagement in this regard and look forward to a response/fix from unity on that matter. I guess i can only wait then, if there is nothing left to test.
Thank you very much nevertheless!
have a nice weekend!

append delete #9. Pierre-Marie Baty

You're welcome. As soon as I have good news from Unity I'll post here.

append delete #10. BadToxic

I ran into this problem https://www.pmbaty.com/iosbuildenv/help/thread.php?path=Problem%20solving/&file=libtool-exe-command-line-can-get-above-the-windows-8k-limit with *Unity 2022.2.14*. Hoping it may be resolved in Unity 2023 I upgraded to the *2023.1.0 beta* and now ran into the problem of this thread.

_fatal error: 'pch-cpp.hpp' file not found_

Is there anything new about these problems?
Or a known Unity version >= 2022.2.14 that works?

append delete #11. Pierre-Marie Baty

Unfortunately no news from Unity on my side. I'm not too surprised, they're so busy that last time it took me months to get a reply...

append delete #12. BadToxic

But doesn't that mean, that no one using the current Unity versions from this and last year, can use your builder? Or do some people not have these issues?
So do you recommend downgrading to an older Unity version? (I assume an older version would still work fine with the current iOS SDK 16.4 and the current version of your builder? The last Unity version I tried, that worked for me, was Unity 2022.1.23, but I only tried it with an older iOS SDK and older builder version.)

append delete #13. Pierre-Marie Baty

No. "No one" is an excessive statement here.

Actually, the majority of users don't have this issue, because in one way or another, the number of files in their Xcode project that il2cpp has to compile is kept low, and it translates in a command-line that's passed to libtool.exe that's under the command-line size limit imposed by Microsoft.

Simplifying/refactoring your Unity project (merging scripts together, etc) would probably help.

append delete #14. BadToxic

Ah of course, sounds plausible, my project is already pretty big.
Merging scripts together sound like the opposite of what a developer should do for keeping clean code. ^^'

I downgraded to Unity 2022.1.24 now and it works again. But I still hope Unity will fix these problems. Did you already report these bugs officially, so others can "sign" (write into the bug report that they also have the problem), to express a higher urgency?

Thank you very much!

append delete #15. Pierre-Marie Baty

No, I sent an email to the person in charge. I don't know if reporting that bug officially would help, because running il2cpp on Windows concerns only a minority of users (i.e. those who use this toolchain). I know that Unity would prefer people to use their Cloud Build system than to use this toolchain.

append delete #16. Jerry

Just to add to this I don't use your software but I am getting this same error with iOS builds running MacOS on Unity 2021.3. Very few mentions of this bug around so looks to be rare, I will try updating Unity as others have to see if that fixes it.

append delete #17. Pierre-Marie Baty

@Jerry: Very interesting. Please let us know if you find a Unity version that works which one it is.

append delete #18. Brett1

Hello. I am also having this issue. I am trying to build on windows with Unity 2023.2.4. Should I start trying older versions of Unity?

append delete #19. Pierre-Marie Baty

Hello Brett

Unfortunately I can't predict whether a particular version will work or not. What I'd rather do, with the understanding of the problem I have so far, is to try to reduce the number of source files the il2cpp compiler has to compile. Perhaps by simplifying the code and/or merging some scripts. A good process would be : arbitrarily halve your codebase where it's most convenient, build. If it builds successfully, put back half of the half you removed. If it works, put back half of the remaining half. Etc. until it no longer works. At which point you get an idea of the "volume" of scripts where the problem starts to occur. It is even possible that a particular script (for example one brought in by a plugin/asset) produces a lot of source files to compile and triggers the case alone.

As the problem seemingly also occurs on macOS, and in all cases in the il2cpp building step which is driven by Unity's il2cpp compiler driver but is a sort of black box for the build system, I don't think I can do anything about it unfortunately, except for providing advice on how to avoid it, hopefully relevant.

append delete #20. 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.

append delete #21. Pierre-Marie Baty

Congratulations for this very interesting finding ! I think the Unity il2cpp dev team should read this.

Your workaround can certainly be automated. PROJECT_DIR is the directory where the .xcodeproj directory itself is. And SRCROOT is the directory where your project sources are. Conveniently on Unity projects they're the same. More info here: https://help.apple.com/xcode/mac/8.3/#/itcaec37c2a6

:: @Pierre-Marie Baty added on 10 Sep ’23 · 15:03

P.S. Use "pbxprojparse -query" to have the toolchain resolve these variables for you :-)

append delete #22. redclad

If it can help, I narrowed down some exact strings to replace in the file project.pbxproj to fix the problem. With these swaps, it was not necessary to check carefully anymore and I can automate the process.
Note: Xcode_project represents the path up to the Xcode project folder.
Note 2: in Notepad++, I had to uncheck "match whole word only" for the program to recognize some strings.

$(SRCROOT)
$(PROJECT_DIR)
$PROJECT_DIR
All three replaced with
C:/Xcode_project

$CONFIGURATION_BUILD_DIR
Replaced with
C:/Xcode_project/build/Release-iphoneos/GameAssembly

path = Il2CppOutputProject/
Replaced with
C:/Xcode_project/Il2CppOutputProject/

path = Libraries/
Replaced with
C:/Xcode_project/Libraries/

"Il2CppOutputProject
Replaced with
"C:/Xcode_project/Il2CppOutputProject

"Libraries
Replaced with
"C:/Xcode_project/Libraries

These replacements were sufficient for my app to be built successfully. No guarantee for others though.

append delete #23. GreenEyedExplorer

Hi. I have written a Python script. Maybe it will help someone:

---

file_path = "g:/folder/Unity-iPhone.xcodeproj/project.pbxproj"
with open(file_path, 'r') as file:
file_content = file.read()
new1 = file_content.replace("$(SRCROOT)", "g:/folder")
new2 = new1.replace("$(PROJECT_DIR)", "g:/folder")
new3 = new2.replace("$PROJECT_DIR", "g:/folder")
new4 = new3.replace("$CONFIGURATION_BUILD_DIR", "g:/folder/build/Release-iphoneos/GameAssembly")
new5 = new4.replace('"Il2CppOutputProject', '"g:/folder/Il2CppOutputProject')
new6 = new5.replace('"Libraries', '"g:/folder/Libraries')
new7 = new6.replace("path = Libraries/", "path = g:/folder/Libraries/")
new8 = new7.replace("path = Il2CppOutputProject/", "path = g:/folder/Il2CppOutputProject/")

with open(file_path, 'w') as file:
file.write(new8)
print("String replaced successfully.")

---

Well, it does not work on Unity 2023.1.11f.
Any progress compiling? Ideas?

append delete #24. Pierre-Marie Baty

Have you made a diff of your files before and after the modification to make sure that your script works as intended ?
I'm not a Python expert, but I see you open your file once in read mode and a second time in write mode without closing it first. In case the Windows implementation of your Python interpreter opens the file with an exclusive lock, your second open() call might fail.

append delete #25. GreenEyedExplorer2

Hi. It changes project.pbxproj even if I do not put file.close() in the app.

It compiles libGameAssembly.a OK, then in the next step "Building the dependency project UnityFramework..." it finds multiple errors:
- redefinition of module 'libxml2' (in Unity\SDK\usr\include\libxml2\libxml/module.modulemap and Unity\SDK\usr\include\libxml/module.modulemap)
- could not build module 'os_workgroup'
- could not build module 'Dispatch'
- could not build module 'CoreFundation'
- could not build module 'Fundation'
- could not build module 'CoreGraphics'
some of these repeat... and than it stops compiling due to 21 errors.

I have tried default script process_symbols.sh and process_symbols_il2cpp.sh with $(PROJECT_DIR) and with supplemented g:/folder... No difference.

Any idea?

append delete #26. Pierre-Marie Baty

This is the same problem as this one:

https://www.pmbaty.com/iosbuildenv/help/thread.php?path=Problem%20solving/&file=fatal-error-could-not-build-module-foundation-error-redefinition-of-module-libxml2-and-more

The Swift interface of the iOS 17 SDK is broken and needs a manual fix documented here. This fix will be automated in the next version of the builder. Apple is probably not aware of this because they supply precompiled Swift modules with Xcode, so the compiler infrastructure doesn't need to recompile the Swift interfaces of the SDK into Swift modules.

append delete #27. Gamester

Following this thread because I cannot build my project for the same reason.
Also having the same issue on my company build machines.

I can confirm this seems to happen when projects are big, and removing code is not something you can do on a profitable released title

append delete #28. Pierre-Marie Baty

Hello

The newest version of the builder (3.60) should fix these problems. Let me know if it was not the case.

append delete #29. Gamester

Hello Pierre,

Just tried the 3.60 update and still no luck :(
- Unity 2023.1.14f1
- Windows 11

ld64.lld: warning: directory not found for option -LC:/Users/migas/Desktop/Megalands/unity_project/Build/iOS/$(BUILT_PRODUCTS_DIR)
ld64.lld: error: undefined symbol: il2cpp_gc_wbarrier_set_field
+ other errors with ld64.lld

Is there e place where the build log is saved btw so I can share more information here?

append delete #30. Pierre-Marie Baty

Hello

Yes, the build log is saved in a file called "build.log" in the Xcode project directory. Post it on https://www.pmbaty.com/paste and put the link here.

But at first sight, I can spot something incorrect. When you installed it, the builder advised you to put your Xcode projects in C:\iOS in opposition to anywhere else, to work around a path length limitation issue (260 characters max) on Windows. You might have skipped that informative dialog box. I suggest doing that first. I don't know if it'll solve exactly this problem, but it'll certainly avoid others.

append delete #31. Gamester

You are correct, I just follow the quick click buttons to install.
I see that the default location given is the "C:\Users\migas\iOS Project Builder for Unity" path.

Could this version have the wrong configuration on the installer?

Will change the locations manually and report back here

append delete #32. Gamester

Ok, I figured out the problem.
I see you using a "File Folder Shortcut" for the builder inside of "C:/iOS" and I was targeting a shortcut directly, where this would map to my project build path.

How do you turn a "File Folder" into a shortcut? the same way you did with "builder" folder?
Seems that right-click on the folder > Create Shortcut, doesn't work for me

append delete #33. Gamester

It seems after some tries, the problem persists.
I know you have another thread on the same topic, so let me know if you want me to change to that thread.

This is the build log

https://www.pmbaty.com/paste/?9cfbbe19de5333be#BcSzeCVgdFzux91XERs47o7x64ThHcdrNRsw2Dfuo49W

append delete #34. Pierre-Marie Baty

How do you turn a "File Folder" into a shortcut?

These are called "symbolic links". You need to use the "mklink /d <link> <target>" command in Administrator mode. If the link and the target are on the same filesystem, you can also use "mklink /j" which creates a "junction" (filesystem reparse point). It behaves somewhat similarly except that it doesn't require admin privileges.

I'll look at the build log.

append delete #35. Pierre-Marie Baty

Would it be possible for you to send me the Xcode project that doesn't build (or a stripped version of it that shows the same behavior) to my email address, so that I can look at it more closely and provide a fix for this problem ? Send it at pm (at) this domain. Confidentiality guaranteed.

Thank you in advance.

append delete #36. Gamester

Email sent with the WeTransfer download link of the Xcode project.
Seems that the new 3.60.1 update doesn't even build for me :(

append delete #37. Pierre-Marie Baty

Thank you for the test case. Indeed I goofed something in this release...

https://www.pmbaty.com/iosbuildenv/help/thread.php?path=Problem%20solving/&file=il2cpp-regression-in-3-60-1-fix-is-on-the-way

As soon as your project builds (and the others of my test lot) I'll push the update.

:: @Pierre-Marie Baty added on 09 Nov ’23 · 19:08

*edit* Done. 3.60.2 is out.

append delete #38. BadToxic

I just wanted to confirm - for me the problem was also solved, thank you very much!

append delete #39. Pierre-Marie Baty

Thanks for the feedback.

Reply

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

There is no need to “register”, just enter the same name + password of your choice every time.

Pro tip: Use markup to add links, quotes and more.

Moderators: Pierre-Marie Baty