FEditorDelegates::EndPIE unresolved external symobol

I’m trying to add EndPIE Delegate but keep getting an error compiling:

#include "Editor.h"
FDelegateHandle EndPIEdelegate = FEditorDelegates::EndPIE.AddUObject(this, &AMyPlayerController::DoEndPIE);
void AMyPlayerController::DoEndPIE(bool boolSent) {

I get the following error:

Severity	Code	Description	Project	File	Line	Suppression State
Error	LNK2001	unresolved external symbol "__declspec(dllimport) public: static class TMulticastDelegate<void,bool const > FEditorDelegates::EndPIE" (__imp_?EndPIE@FEditorDelegates@@2V?$TMulticastDelegate@X$$CB_N@@A)	Jigsaw	C:\Users\TV2\Documents\Unreal Projects\Jigsaw\Intermediate\ProjectFiles\MyPlayerController.cpp.obj	1

Dear valued Unreal Engine user,

Is UnrealEd correctly specified as a dependency in your module’s .build.cs file? e.g.

        if (Target.Type == TargetRules.TargetType.Editor)
            PublicDependencyModuleNames.AddRange(new string[] { "UnrealEd" });

Another area check is that the code you posted looks a bit strange. You would probably benefit from putting the FEditorDelegates::EndPIE.AddUObject(this, &AMyPlayerController::DoEndPIE) code inside an Initializer e.g. AMyPlayerController::Initialize() and wrap it in WITH_EDITOR.

Thank you for your continued support,