Unreal Module "PropertyEditor" obstructs packaging

I have been trying to edit how properties get displayed in, for example, a DataTable, for various reasons, and for that I have included several modules such as Slate, SlateCore and the PropertyEditor.

In the editor it works, but when I package, I get a linking error. After research I found out I have to add some modules only when I actually build with the editor, so I have added the following code to the .build.cs:

 if (Target.bBuildEditor)
        {
            PrivateDependencyModuleNames.AddRange(new string[] { "UMG", "Slate", "SlateCore" });
            PublicDependencyModuleNames.AddRange(new string[] { "PropertyEditor" });
        }

The compilation works flawlessly, the packaging however does not. Two errors I get are the following:

“C:\Program Files\Epic Games\UE_4.19\Engine\Source\Editor/PropertyEditor/Public/PropertyEditorModule.h(9): fatal error C1083: Cannot open include file: ‘Toolkits/IToolkitHost.h’: No such file or directory”

as well as

“c:\users\userA\documents\unreal projects\projectX\source\projectX\core\ConditionCustomization.h(5): fatal error C1083: Cannot open include file: ‘IPropertyTypeCustomization.h’: No such file or directory”

The former I don’t really know anything about as that’s not my code. The latter, ConditionCustomization.h is written by me and includes the “IPropertyTypeCustomization.h”

My guess is that since packaging builds without the editor, and ConditionCustomization.h gets compiled, yet it can’t access the IPropertyTypeCustomization header since the module is not included, it fails.

I need to “not-include” editor specific modules such as PropertyEditor when packaging, but I also need to make sure that the code I have written that references those modules gets excluded. How do I do that?

Did you ever resolve this? Just started getting these errors after upgrading to 4.19 and trying to build a Test build

Yes.

Apparently it’s related to editor-modules being included in runtime-builds that strip out editor functionality. So it basically complains because you expect it to have editor functionality when it simply doesn’t. I created a new module, defined it as an editor module, which then included the necessary editor modules.

You shoud look up how to create modules yourself, but I can tell you a few keywords to search for:

  1. .uproject file needs to have the module defined (editor module)

  2. In the .Build.cs file of the module, you include the editor modules that you need

  3. In the project .Build file (your game’s .Build.cs) you write in the constructor where the ModuleNames are added:

    if(Target.Type == TargetType.Editor)
    {
    PublicDependencyModuleNames.Add(“EditorModuleName”);
    }

This ensures that this new module of yours only gets included when building for the editor, and this module itself then is responsible for including the necessary editor modules.

You should be able to, however, if you don’t have custom editor code but just want to use an editor module, be able to step 3) with the modules you need instead of writing your own module that in turn includes those other modules.

Cool thanks, Yep I found that the problem in our project was that in the 4.19 upgrade I’d changed from:

if(Target.Type == TargetType.Editor)

to the bBuildEditor option instead, but bBuildEditor was always true. Then I realised that the if statement was probably from legacy anyway and I could remove that code from the non-editor module file completely.

Thanks again