UCLASS is giving me an error when I try to add a HEADER. How do I fix this?

Change

USplineComponent* PathSpline;

to

class USplineComponent* PathSpline;

and then in your cpp file on top add this #include "Runtime/Engine/Classes/Components/SplineComponent.h"


I’m trying to create a Spline Actor Component for:

 private:
     UPROPERTY(EditAnywhere, Instanced, Category = "Path spline")
         USplineComponent* PathSpline;

And whenever I add this HEADER my UCLASS() keeps getting an error:

#include "Runtime/Engine/Classes/Components/SplineComponent.h"

Error message I get from UCLASS

"This declaration has no storage class or type specifier"

#pragma once


#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MySplineActorComponent.generated.h"

#include "Runtime/Engine/Classes/Components/SplineComponent.h"

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

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

private:
	UPROPERTY(EditAnywhere, Instanced, Category = "Path spline")
		USplineComponent* PathSpline;
	
};

"#include “Runtime/Engine/Classes/Components/SplineComponent.h” needs to go before the .generated header:

 #include "CoreMinimal.h"
 #include "GameFramework/Actor.h"
 #include "Runtime/Engine/Classes/Components/SplineComponent.h"
 #include "MySplineActorComponent.generated.h"

Or you could just forward declare the class at the top:

class USplineComponent;