Cannot open source file name.generated.hc

I had the same issue as well, I tried deleting all the files and rebuilding but it still didn’t work.
Later I noticed in VS output log “XYZ.generated.h file should always be the last”, I noticed that I had added another #include line after #include “XYZ.generated.h” which caused the error.

Since this thread is the first result when I google this problem, I figured I will also provide my solution to this problem.

For me, the problem was that I accidentally included the class prefix in the file name (i.e. I had a class called “FMyStruct”, and I accidentally called the file name “FMyStruct.h”). This breaks the build system, eventually I noticed this problem and corrected it by changing the file name to “MyStruct.h” (note that it no longer includes the ‘F’ prefix).

Thank you! It will be useful for newcomers. I am one of them :slight_smile:

This was also my problem. The problematic file was listed one line above the error in Rider’s build log. It seems for some reason I had an include line in my Character.cpp file for a random header from the engine source that I wasn’t even using. Not sure how it got there. In any case error went away after removing it