How do we exclude editor modules from non-editor configurations in 4.16?

This worked for me, thanks!

Thanks a lot, you save my day haha :wink: The documentation for creating a module editor hasn’t change, so I was blocked to create my first one. I think it’s because of that (not sure) :slight_smile:

In 4.16, the TargetRules class (the class defined in a module’s .Target.cs file) changed, and the SetupBinaries function was deprecated.

In 4.15 and before, the usual method for adding an Editor Module to a project was to add it to the ExtraModuleNames array in SetupBinaries if UEBuildConfiguration.bBuildEditor was true.

In 4.16, adding these ExtraModuleNames needed to get moved into the target constructor. However, it appears that in the constructor. UEBuildConfiguration.bBuildEditor is always true, even for configurations where the editor should not be built. This means that using the old method (just moved to the constructor from SetupBinaries) any Editor Modules are always included in the build, which will frequently cause build failures when your Editor Module starts trying to reference editor-only files or data which aren’t included in non-editor builds.

Does anyone have any clue as to how we should be excluding Editor Modules from our main module’s Target class in 4.16?

I think I’ve solved it.

Target.Type == TargetType.Editor

I no longer get errors related to editor-only types when compiling Development or DebugGame, and my editor module functionality still works when I compile with DebugGame Editor or Development Editor.

Packaging a project is still failing when cooking assets, but so far it doesn’t seem to be related to this.