# How to deal with Editor-only Modules in non-Editor build targets?

**URL:** <https://forums.unrealengine.com/t/how-to-deal-with-editor-only-modules-in-non-editor-build-targets/1340279>\
**Category:** Platform & Builds\
**Tags:** target, modules, build, unreal-engine, Shipping, question\
**Created:** [October 21, 2023, 11:41pm UTC](https://forums.unrealengine.com/t/how-to-deal-with-editor-only-modules-in-non-editor-build-targets/1340279 "2023-10-21T23:41:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dzemzmcdonalda](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dzemzmcdonalda/32/1214680_2.png) [@dzemzmcdonalda](https://forums.unrealengine.com/u/dzemzmcdonalda)\
**Post date:** [October 21, 2023, 11:41pm UTC](https://forums.unrealengine.com/t/how-to-deal-with-editor-only-modules-in-non-editor-build-targets/1340279/1 "2023-10-21T23:41:24Z")

</div>

Hello,

My project depends on a plugin, and said plugin depends on “UnrealEd” module.  
I need to make it build as Cooked non-Editor Target (e.g. “Shipping”).

In [project].build.cs the plugin module gets included as private dependency.  
In [plugin].build.cs the “UnrealEd” module is also getting included as private dependency.  
All code written in the plugin that depends on headers from “UnrealEd” is wrapped by `#if WITH_EDITOR` preprocesor directive.  
in [plugin].uplugin the “Type” is set to “Runtime”

Whenever I try to build “Shipping” target, I am getting following error:

```auto
Unable to instantiate module 'UnrealEd': Unable to instantiate UnrealEd module for non-editor targets.
(referenced via Target -> [plugin].Build.cs)

```

I believe that this is caused by setting the plugin to “Runtime” type.  
However, I need to use this module at runtime during gameplay.

I fought that having a module as private dependency will be enough to prevent it from getting included in some build targets, but this doesn’t seem to work such way.

I’m struggling to figure this out. Am I missing something?  
Is there any way to solve this?

Thanks!

---

<div class="post-metadata">

**Author:** ![dzemzmcdonalda](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dzemzmcdonalda/32/1214680_2.png) [@dzemzmcdonalda](https://forums.unrealengine.com/u/dzemzmcdonalda)\
**Post date:** [October 22, 2023, 12:54am UTC](https://forums.unrealengine.com/t/how-to-deal-with-editor-only-modules-in-non-editor-build-targets/1340279/2 "2023-10-22T00:54:53Z")

</div>

I tried to fix it by moving the code dependent on “UnrealEd” to yet another module, let’s call this module “PluginEditor”.

So now my plugin has two modules - “PluginRuntime” and “PluginEditor”

and `[plugin].uplugin` contains:

```auto
"Modules": [
	{
		"Name": "PluginEditor",
		"Type": "Editor",
		"LoadingPhase": "PreDefault"
	},
	{
		"Name": "PluginRuntime",
		"Type": "Runtime",
		"LoadingPhase": "Default"
	}
]

```

`[project].Build.cs` contains:

```auto
PrivateDependencyModuleNames.AddRange(new string[]{"PluginCore",});

```

`PluginCore.Build.cs` contains:

```auto
PrivateDependencyModuleNames.AddRange(new string[]{"PluginEditor",});

```

and `PluginEditor.Build.cs` contains:

```auto
PrivateDependencyModuleNames.AddRange(new string[]{"UnrealEd",});

```

According to [Plugins in Unreal Engine | Unreal Engine 5.2 Documentation](https://docs.unrealengine.com/5.2/en-US/plugins-in-unreal-engine/)  
this now should build in the Shipping, right? Right???  
NO, it doesn’t, at least not for me:

```auto
Unable to instantiate module 'UnrealEd': Unable to instantiate UnrealEd module for non-editor targets.
(referenced via Target -> PluginCore.Build.cs -> PluginEditor.Build.cs)

```

(toooo bad…)

I have no idea what I’m doing wrong.  
Feeling hopeless at this point.

---

<div class="post-metadata">

**Author:** ![dzemzmcdonalda](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dzemzmcdonalda/32/1214680_2.png) [@dzemzmcdonalda](https://forums.unrealengine.com/u/dzemzmcdonalda)\
**Post date:** [October 22, 2023, 1:40am UTC](https://forums.unrealengine.com/t/how-to-deal-with-editor-only-modules-in-non-editor-build-targets/1340279/3 "2023-10-22T01:40:48Z")

</div>

Okey, found the solution, here:

> [@UnrealEd Dependency Causes Package Failure](https://forums.unrealengine.com/t/unrealed-dependency-causes-package-failure/19940/8):
>
> Working code from 2020. \*.Build.cs: using UnrealBuildTool; public class TanksVr : ModuleRules { public TanksVr(ReadOnlyTargetRules target) : base(target) { PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; bEnforceIWYU = true; PublicDependencyModuleNames.AddRange(new ] { "Core", "CoreUObject", "Engine", "PhysXVehicles", "HeadMountedDisplay", …

Changing module “Type” did nothing in my case.

I merged the two modules back to only one and used the following condition in `[plugin].Build.cs` :

```auto
if (Target.bBuildEditor)
{
    PublicDependencyModuleNames.AddRange(new string[]{"UnrealEd",});
}

```

I also had to wrap every header that comes from “UnrealEd” with `#if WITH_EDITOR`

My project finally compiles to Shipping 😌

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [November 21, 2023, 1:41am UTC](https://forums.unrealengine.com/t/how-to-deal-with-editor-only-modules-in-non-editor-build-targets/1340279/4 "2023-11-21T01:41:31Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
