Rocket build expects FILE.h to be first include... but building from VS expects MODULE.h instead

Hi guys… trying to create a rocket build for my plugin (for testing purposes) and this error comes


Performing full C++ include scan (building a new target)
Creating makefile for UE4Editor (no existing makefile)
Parsing headers for UE4Editor
  Running UnrealHeaderTool "C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\HostProject.uproject" "C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
Reflection code generated for UE4Editor in 16.3807803 seconds
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZD\Private\PaperZDAnimBP.cpp(1): error: Expected PaperZDAnimBP.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZD\Private\PaperZDAnimInstance.cpp(1): error: Expected PaperZDAnimInstance.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZD\Private\PaperZDCharacter.cpp(1): error: Expected PaperZDCharacter.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZD\Private\AnimNodes\PaperZDAnimNode.cpp(1): error: Expected PaperZDAnimNode.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZD\Private\AnimNodes\PaperZDAnimNode_Root.cpp(1): error: Expected PaperZDAnimNode_Root.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZD\Private\AnimNodes\PaperZDAnimNode_State.cpp(1): error: Expected PaperZDAnimNode_State.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZD\Private\AnimNodes\PaperZDAnimNode_Transition.cpp(1): error: Expected PaperZDAnimNode_Transition.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZD\Private\Notifies\PaperZDAnimNotify.cpp(1): error: Expected PaperZDAnimNotify.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZD\Private\Notifies\PaperZDAnimNotifyCustom.cpp(1): error: Expected PaperZDAnimNotifyCustom.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZD\Private\Notifies\PaperZDAnimNotifyState.cpp(1): error: Expected PaperZDAnimNotifyState.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZD\Private\Notifies\PaperZDAnimNotify_Base.cpp(1): error: Expected PaperZDAnimNotify_Base.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZD\Private\Notifies\PaperZDAnimNotify_PlaySound.cpp(1): error: Expected PaperZDAnimNotify_PlaySound.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\AssetTypeActions\AssetTypeActions_PaperZDAnimBP.cpp(1): error: Expected AssetTypeActions_PaperZDAnimBP.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Compilers\PaperZDCompilerContext.cpp(1): error: Expected PaperZDCompilerContext.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Editors\PaperZDAnimBPEditor.cpp(1): error: Expected PaperZDAnimBPEditor.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Editors\PaperZDStateViewportClient.cpp(1): error: Expected PaperZDStateViewportClient.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Editors\Slate\SPaperZDAnimNotifyPanel.cpp(1): error: Expected SPaperZDAnimNotifyPanel.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Editors\Slate\SPaperZDConfirmDialog.cpp(1): error: Expected SPaperZDConfirmDialog.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Editors\Slate\SPaperZDStateViewport.cpp(1): error: Expected SPaperZDStateViewport.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Factories\PaperZDAnimBPFactory.cpp(1): error: Expected PaperZDAnimBPFactory.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Graphs\PaperZDAnimGraph.cpp(1): error: Expected PaperZDAnimGraph.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Graphs\PaperZDAnimGraphSchema.cpp(1): error: Expected PaperZDAnimGraphSchema.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Graphs\PaperZDAnimTransitionGraph.cpp(1): error: Expected PaperZDAnimTransitionGraph.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Graphs\PaperZDAnimTransitionGraphSchema.cpp(1): error: Expected PaperZDAnimTransitionGraphSchema.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Graphs\PaperZDNotifyGraph.cpp(1): error: Expected PaperZDNotifyGraph.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Graphs\PaperZDStateMachineConnectionDrawingPolicy.cpp(1): error: Expected PaperZDStateMachineConnectionDrawingPolicy.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Graphs\Nodes\PaperZDAnimGraphNode.cpp(1): error: Expected PaperZDAnimGraphNode.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Graphs\Nodes\PaperZDAnimGraphNode_Root.cpp(1): error: Expected PaperZDAnimGraphNode_Root.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Graphs\Nodes\PaperZDAnimGraphNode_State.cpp(1): error: Expected PaperZDAnimGraphNode_State.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Graphs\Nodes\PaperZDAnimGraphNode_Transition.cpp(1): error: Expected PaperZDAnimGraphNode_Transition.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Graphs\Nodes\PaperZDTransitionGraphNode_Result.cpp(1): error: Expected PaperZDTransitionGraphNode_Result.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Graphs\Nodes\Slate\SPaperZDAnimGraphNode_Root.cpp(1): error: Expected SPaperZDAnimGraphNode_Root.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Graphs\Nodes\Slate\SPaperZDAnimGraphNode_State.cpp(1): error: Expected SPaperZDAnimGraphNode_State.h to be first header included.
C:\Users\DarkK\Documents\Unreal Projects\PaperZD_Builds\4.18_build\HostProject\Plugins\PaperZD\Source\PaperZDEditor\Private\Graphs\Nodes\Slate\SPaperZDAnimGraphNode_Transition.cpp(1): error: Expected SPaperZDAnimGraphNode_Transition.h to be first header included.
ERROR: Build canceled.

The problem is that… if i change EVERY include from my cpp… then the project won’t compile because it expects the Module.h to be the first included… so the point… is that i cannot build the project on rocket and on the editor at the same time…

Having pretty much the same issue…I’m stumped.

Since 4.18, all plugins are supposed to use IWYU. You can see how it works here: https://docs.unrealengine.com/latest/INT/Programming/UnrealBuildSystem/IWYUReferenceGuide/

It’s not enforced properly, so building from VS might still work without having it set, while attempting to package the plugin overrides it to be enabled.

Maybe? I don’t know how your project looks like.
One of the basic rules of IWYU is that each .cpp includes the .h with the same name first, if there is one.

mmm i think that could be it… but that means my 4.18 project is not using IWYU?

i mean, just created a blank c++ project on 4.18 preview 2 (if i remember correctly), failed inmediately as the MODULE.h was expected first

PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

exists on the game
not on the plugin… could that be the issue?

Do you see this line in your Build.cs file?

PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

If not, try adding it.

Yeah, try adding it in the plugin too.