Error on xCode Compile

I’m doing the intro cpp on unreal engine but i’m having a problem when i’m trying to build the project on xcode.

i get the error:

Setting up Mono
Building IntroCPPDocs...
Compiling with Mac SDK 10.10
Parsing headers for IntroCPPDocs
/Users/marchiore/Documents/Unreal Projects/IntroCPPDocs/Source/IntroCPPDocs/MyActor.h(13) : Error: In MyActor: BlueprintReadWrite should not be used on private members

Error: Failed to generate code for IntroCPPDocs - error code: OtherCompilationError (2)
UnrealHeaderTool failed for target 'IntroCPPDocs' (platform: Mac, module info: /Users/marchiore/Documents/Unreal Projects/IntroCPPDocs/Intermediate/Build/Mac/IntroCPPDocs/DebugGame/UnrealHeaderTool.manifest).
Command /Users/Shared/UnrealEngine/4.7/Engine/Build/BatchFiles/Mac/RocketBuild.sh failed with exit code 2

I have to install something?

Looks like your variable is not in the “public scope” (google: public private scope C++).

A basic fix would be to add “public:” on the line above your UPROPERTY but it’s possible something else is also wrong because I think the normal unreal macros leave everything public.

Can you attach your code file here?

MyActor.cpp

// Fill out your copyright notice in the Description page of Project Settings.

#include "IntroCPPDocs.h"
#include "MyActor.h"


// Sets default values
AMyActor::AMyActor()
{
    TotalDamage = 200;
    DamageTimeInSeconds = 1.f;
    
 	// 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 );

}

MyActor.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

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

UCLASS()
class INTROCPPDOCS_API AMyActor : public AActor
{
    GENERATED_BODY()
    
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Damage")
    int32 TotalDamage;
    
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Damage")
    float DamageTimeInSeconds;
    
    UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Transient, Category="Damage")
    float DamagePerSecond;
	
public:	
	// Sets default values for this actor's properties
	AMyActor();

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

	
	
};

Not sure what it’s complaining about.

According to my local source GENERATED_BODY leaves the scope public on its last line.

Suggestions, in the order I’d try them:

  1. Remove your “public:” and see if that fixes anything, the script that generates the generated file might be confused.

  2. Remove each UPROPERTY in turn to see which one might be causing the problem.

  3. Put: public: on the line after GENERATED_BODY()

Ok, when i get home i’ll try it.Thanks!

Just created my first new actor class in 4.7 and got the same error!

Move the public: above the first UPROPERTY and it should compile.

Did that fix it?

Yes, it Works! Thanks!!

This fixed the problem for me. Not sure about the OP. Thanks!

This fixed it for me as well.

Should be noted that moving the UPROPERTY macro to public was only required if I specified BlueprintReadWrite or BlueprintReadOnly.