Trying to spawn actors from C++, keep getting error MSB3070, exited with code -1

Hello, I am currently trying to learn how to spawn actors in C++. I took a brief look in how they did it in First Person Template and coded my function like so:

void AHeroShip::SpawnShield()
{
	if (Energy >= 50 && ShieldClass != NULL)
	{

		const FRotator SpawnRotation = GetControlRotation();
		const FVector SpawnLocation = GetActorLocation() + SpawnRotation.RotateVector(ShieldOffset);

		UWorld* const World = GetWorld();
		if (World != NULL)
		{
			Energy -= 50.f;
			World->SpawnActor<Shield>(ShieldClass, SpawnLocation, SpawnRotation);
		}
	}
}

Which then I know I’m supposed to say what the class is in blueprint, but I keep getting the error (MSB3070, exited with code -1) Normally, I’m good at finding these bugs and fixing them, but I can’t find out what is wrong with the code, any ideas why this might be happening? Any help would be appreciated.

Here is the .h file, I’ll also will link the .cpp file if anyone needs to see it.:

#pragma once

#include "BaseShip.h"
#include "HeroShip.generated.h"

/**
 * 
 */
UCLASS(Blueprintable)
class TWINSTICKEXAMPLE_API AHeroShip : public ABaseShip
{
	GENERATED_BODY()

public:
	
	AHeroShip();

	//Ammo Types
	float BounceShotAmmo;
	float SpreadShotAmmo;
	float BeamShotAmmo;
	
	bool isLow;

	UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "GunType")
		int32 Type;

	UPROPERTY(EditDefaultsOnly, Category = "Shield")
		TSubclassOf<class Shield> ShieldClass;

	//Any offsets
	FVector UDOffset;
	FVector ShieldOffset;

	FTimerHandle EnergyDepleteBoost;
	FTimerHandle RestoreEnergyTimer;

protected:
	
	//movement
	void MoveForward(float Delta);
	void MoveRight(float Delta);
	void MoveUD(); //Move either up or down
	void Boost();
	void notBoost();

	//EnergyBased Spawns
	void SpawnShield();

	//Gun
	void SetToAuto();
	void SetToBounce();
	void SetToSpread();
	void SetToBeam();

	void RestoreEnergy();

	virtual void SetupPlayerInputComponent(UInputComponent* InputComponent) override;
	
};

I’m sorry but what is Shield? Is it derived from AActor?

For me, I perform the following when spawning actors:

.h
TSubclassOf<class AMyPawn>  MyPawn;

.cpp
AMyPawn* pawn = GetWorld()->SpawnActor<AMyPawn>(MyPawn, spawnLocation, spawnRotation);

Btw, I thought UE4 by convention requires classes derived from AActor to start with A, as in AShield. If my understanding is correct you may be able to:

.h
TSubclassOf<class AShield> Shield;

.cpp
World->SpawnActor(Shield, SpawnLocation, SpawnRotation);

Hello, sorry for the late response. I ended up having to scrap the whole project because the base character wasn’t working properly (Errors were everywhere, and I didn’t change anything.) But thanks for your help anyhow. :confused: