# UnrealEd Dependency Causes Package Failure

**URL:** <https://forums.unrealengine.com/t/unrealed-dependency-causes-package-failure/19940>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [January 30, 2015, 4:52am UTC](https://forums.unrealengine.com/t/unrealed-dependency-causes-package-failure/19940 "2015-01-30T04:52:41Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mentos](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mentos](https://forums.unrealengine.com/u/Mentos)\
**Post date:** [January 30, 2015, 4:52am UTC](https://forums.unrealengine.com/t/unrealed-dependency-causes-package-failure/19940/1 "2015-01-30T04:52:41Z")

</div>

Might anyone know why including “UnrealEd” in Private or Public dependencies in Game.build.cs causes an UnrealBuildTool failure?

If you create a C++ ShooterGame project and add that dependency it will fail to package. Not sure if there is another dependency to include or a missing .dll somewhere?

---

<div class="post-metadata">

**Author:** ![Michael\_Noland](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/michael_noland/32/1194689_2.png) [@Michael\_Noland](https://forums.unrealengine.com/u/Michael_Noland)\
**Post date:** [January 30, 2015, 5:01am UTC](https://forums.unrealengine.com/t/unrealed-dependency-causes-package-failure/19940/2 "2015-01-30T05:01:56Z")

</div>

You will need to create a separate editor-only module if you plan on using stuff from UnrealEd in your game. Add the dependency to that module instead of your runtime module, and don’t include it when cooking.

For example, QAGame.uproject looks like this:

```auto

{
	"FileVersion": 3,
	"EngineVersion": "1595950",
	"PackageFileUE4Version": "226",
	"PackageFileLicenseeUE4Version": "0",
	"Modules": 
		{
			"Name": "QAGame",
			"Type": "Runtime",
			"LoadingPhase": "Default"
		},
		{
			"Name": "QAGameEditor",
			"Type": "Editor",
			"LoadingPhase": "Default"
		}
	]
}

```

Cheers,  
Michael Noland

---

<div class="post-metadata">

**Author:** ![Mentos](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mentos](https://forums.unrealengine.com/u/Mentos)\
**Post date:** [January 30, 2015, 4:12pm UTC](https://forums.unrealengine.com/t/unrealed-dependency-causes-package-failure/19940/3 "2015-01-30T16:12:28Z")

</div>

Michael, thank you very much for the quick response!

I’ve setup a new module that encapsulates my editor code and I am able to get it to compile. However when I package I still run into the same issue, I thought the ‘Type’:‘Editor’ would take care of the ‘don’t include it when cooking’ part of your suggestion but I’m guessing that is not enough.

Might anyone know how can I make it so that my new editor module is not included when I package the game?

---

<div class="post-metadata">

**Author:** ![Michael\_Noland](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/michael_noland/32/1194689_2.png) [@Michael\_Noland](https://forums.unrealengine.com/u/Michael_Noland)\
**Post date:** [January 30, 2015, 6:19pm UTC](https://forums.unrealengine.com/t/unrealed-dependency-causes-package-failure/19940/4 "2015-01-30T18:19:22Z")

</div>

Make sure you aren’t depending on the module in your Target.cs when doing a game build in your SetupBinaries. You’d want to do something like this if you have to link it into the game in an editor build:

```auto

        if (UEBuildConfiguration.bBuildEditor)
        {
            OutExtraModuleNames.Add("QAGameEditor");
        }

```

Cheers,  
Michael Noland

---

<div class="post-metadata">

**Author:** ![Mentos](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mentos](https://forums.unrealengine.com/u/Mentos)\
**Post date:** [January 30, 2015, 9:42pm UTC](https://forums.unrealengine.com/t/unrealed-dependency-causes-package-failure/19940/5 "2015-01-30T21:42:27Z")

</div>

Hmm so if I add my ‘ShooterGameEditor’ module to either the Private/PublicDependencyModuleNames then I can #include “ShooterGameEditor.h” where I want to access the editor code and everything works great in the editor. However, when packaging the game I get an UnrealBuildTool failure as previously noted.

If I remove the ‘ShooterGameEditor’ module from Private/PublicDependencyModuleNames and instead include it

if (UEBuildConfiguration.bBuildEditor)  
{  
OutExtraModuleNames.Add(“ShooterGameEditor”);  
}

within the respective Target.cs files this causes the compiler to complain of a ‘fatal error C1083: Cannot open include file: ‘ShooterGameEditor.h’: No such file or directory’

So I’m not really sure how I can solve this, I’ve followed these two approaches and a combination of both to no avail :\

approach 1) [https://answers.unrealengine.com/questions/41509/extending-editor-engine.html](https://answers.unrealengine.com/questions/41509/extending-editor-engine.html)  
approach 2) [https://docs.unrealengine.com/latest/INT/Programming/Modules/Gameplay/index.html](https://docs.unrealengine.com/latest/INT/Programming/Modules/Gameplay/index.html)

---

<div class="post-metadata">

**Author:** ![Michael\_Noland](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/michael_noland/32/1194689_2.png) [@Michael\_Noland](https://forums.unrealengine.com/u/Michael_Noland)\
**Post date:** [January 30, 2015, 9:54pm UTC](https://forums.unrealengine.com/t/unrealed-dependency-causes-package-failure/19940/6 "2015-01-30T21:54:09Z")

</div>

Use #if WITH\_EDITOR around code you want to exclude from runtime builds, but ideally your runtime code doesn’t depend on your editor code (only the other way around). What is your specific use case?

Cheers,  
Michael Noland

---

<div class="post-metadata">

**Author:** ![Mentos](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mentos](https://forums.unrealengine.com/u/Mentos)\
**Post date:** [January 30, 2015, 10:44pm UTC](https://forums.unrealengine.com/t/unrealed-dependency-causes-package-failure/19940/7 "2015-01-30T22:44:14Z")

</div>

I was able to resolve this by checking if the build was an editor build before including ‘UnrealEd’ dependency and wrapping the code that depends on it with #if WITH\_EDITOR

```auto

        if (UEBuildConfiguration.bBuildEditor)//we only want this to be included for editor builds but not packaged builds
        {
            PublicDependencyModuleNames.AddRange(
                new string] {
                    "UnrealEd",
			    }
            );
        }

```

```auto

#if WITH_EDITOR
#include "LevelUtils.h"
#include "LevelEditor.h"
#endif
...

bool ADoWPlayerController::IsGameMultiplePIE()
{
	bool IsGamePie = (GetWorld()->WorldType == EWorldType::PIE);
	bool IsDedicated = false;
	int32 NumberOfClients = 0;

#if WITH_EDITOR
	ULevelEditorPlaySettings* PlayInSettings = Cast<ULevelEditorPlaySettings>(ULevelEditorPlaySettings::StaticClass()->GetDefaultObject());
	PlayInSettings->GetPlayNetDedicated(IsDedicated);
	PlayInSettings->GetPlayNumberOfClients(NumberOfClients);
#endif

	return IsGamePie && (NumberOfClients > 1 || IsDedicated);
}

```

Thank you Michael for the help!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_7f511785](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_7f511785](https://forums.unrealengine.com/u/anonymous_user_7f511785)\
**Post date:** [May 23, 2020, 7:51pm UTC](https://forums.unrealengine.com/t/unrealed-dependency-causes-package-failure/19940/8 "2020-05-23T19:51:52Z")

</div>

Working code from 2020.

\*.Build.cs:

```auto

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",
                    "InputCore",
                    "Networking",
                    "Sockets",
                    "Json",
                    "JsonUtilities",
                    "GameplayAbilities",
                    "GameplayTags",
                    "GameplayTasks",
                    "AIModule",
               });

          if (target.bBuildEditor)
          {
               PublicDependencyModuleNames.AddRange(new ]
                    {
                         "UnrealEd",
                    });
          }
     }
}

```

Somewhere in code:

```auto

#if WITH_EDITOR
#include "UnrealEd.h"
#endif

......

void ATankSpawnPointSelector::UpdateDrawing()
{
#if WITH_EDITOR
     if (GEditor != nullptr)
     {
          GEditor->RedrawLevelEditingViewports();
     }
#endif
}

```

---

<div class="post-metadata">

**Author:** ![Aherys](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/aherys/32/1194650_2.png) [@Aherys](https://forums.unrealengine.com/u/Aherys)\
**Post date:** [November 4, 2020, 7:23pm UTC](https://forums.unrealengine.com/t/unrealed-dependency-causes-package-failure/19940/9 "2020-11-04T19:23:31Z")

</div>

Dude, loving you @**[Elapotp](https://forums.unrealengine.com/member/3520432-elapotp)**
