Adding Actor-derived class to a plugin causes a lot of errors

I’m writing a plugin based off the Blueprint Library plugin template. Compiling based off the template with no additional classes works as intended.

I’ve added a class to it based off of Actor using the New C++ Class wizard from the Content Browser. The one compiler error caused by this mentions that I need to include MyPluginPrivatePCH in the MyActor CPP file.

Doing this produces a deluge of compiler errors [ Link] in ComponentInstanceDataCache.h, EngineBaseTypes.h, Map.h, and UObject.h, the nature of which has me a bit perplexed. I’m organizing something here incorrectly, but I haven’t got the foggiest idea what.

Current files are as follows:

In Private:

  • MyActor.cpp
  • MyActor.h
  • MyPlugin.cpp
  • MyPluginBPLibrary.cpp
  • MyPluginPrivatePCH.h

In Public:

  • MyActor.h
  • MyPluginBPLibrary.h

In Source:

  • MyPlugin.uplugin

The Actor has no changes to it except that I’ve added an #include to MyPluginPrivatePCH in the CPP, per the instructions in the Visual Studio output.

MyActor.h:

#pragma once

#include "GameFramework/Actor.h"
#include "MyActor.generated.h"

UCLASS()
class AMyActor : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	MyActor();

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;

	
	
};

MyActor.cpp

#include "MyPluginPrivatePCH.h"
#include "MyPlugin.h"
#include "MyActor.h"

// Sets default values
AMyActor::AMyActor()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

}

// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
	Super::BeginPlay();
	
}

// Called every frame
void AMyActor::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

}

Finally: In Build.cs, I am including Core, CoreUObject, Engine, InputCore, and UnrealEd as private dependency module names.

Found my answer.

You must edit MyPluginPrivatePCH.h to #include “Engine.h”. Otherwise it builds all of these in an incorrect order, causing the errors listed in the attached file. Then the plugin builds properly, engine classes and all.