Can't compile code when packaging

Hi.

My code

UBlueprint * bp = Cast<UBlueprint>(cls);
field3.FieldValue = bp->GetFriendlyName();

compiles well in UE Editor.

But this code can’t be compiled on game packaging. It gets error:

 Packaging (Windows (64-bit)): UnrealBuildTool: MyGame.generated.cpp
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: C:\Art\Projects\3D\MyGame\Source\MyGame\MyNativePlayerController.cpp(47) : error C2039: 'GetFriendlyName' : is not a member of 'UBlueprint'
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool:         C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Engine\Classes\Engine/Blueprint.h(266) : see declaration of 'UBlueprint'
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: C:\Art\Projects\3D\MyGame\Source\MyGame\MyNativePlayerController.cpp(116) : warning C4996: 'AStaticMeshActor::StaticMeshComponent': StaticMeshComponent should not be accessed directly, please use GetStaticMeshComponent() function instead. StaticMeshComponent will soon be private and your code will not compile. Please update your code to the new API before upgrading to the next release, otherwise your project will no longer compile.
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool:         C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Engine\Classes\Engine/StaticMeshActor.h(23) : see declaration of 'AStaticMeshActor::StaticMeshComponent'
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: MyFurnitureActor.cpp
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: MyGame.cpp
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: -------- End Detailed Actions Stats -----------------------------------------------------------
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: ERROR: UBT ERROR: Failed to produce item: C:\Art\Projects\3D\MyGame\Binaries\Win64\MyGame.exe

As I see, in Blueprint.h
virtual FString GetFriendlyName() const;
wrapped by

#if WITH_EDITOR

How can I compile this code on packaging?

upupupupup

First question is do you really need it? You are going to be packaging a whole bunch of data into your game, for every BP there’s an extra string, which is going to burn through memory.

What do you need that value for? Is it debugging? Is there not another way of storing that value, IIRC there’s a blueprint ID value?

Hi!

A blueprint ID value?

Yes, for an actor it’s GetUniqueID();

Solved by changing logic of the indexing (that used bp->GetFriendlyName(); in the past) - How to find blueprints by parent BP? - Blueprint - Epic Developer Community Forums