I faced some problem in unreal while changing from blueprint to c++ code in project setting in unreal engine 4.27.2

The project could not be compiled. Would you like to open it in Xcode?

Running Mono…

Running bundled mono, version: Mono JIT compiler version 5.16.0.220 (2018-06/bb3ae37d71a Fri Nov 16 17:12:11 EST 2018)
/Users/Shared/Epic Games/UE_4.27/Engine /Users/Shared/Epic Games/UE_4.27/Engine/Binaries/Mac
Creating makefile for MyProject2123Editor (no existing makefile)
@progress push 5%
Parsing headers for MyProject2123Editor
Running UnrealHeaderTool “/Users/sagardwevedi/Documents/Unreal Projects/MyProject2123/MyProject2123.uproject” “/Users/sagardwevedi/Documents/Unreal Projects/MyProject2123/Intermediate/Build/Mac/x86_64/MyProject2123Editor/Development/MyProject2123Editor.uhtmanifest” -LogCmds=“loginit warning, logexit warning, logdatabase error” -Unattended -WarningsAsErrors -abslog="/Users/sagardwevedi/Library/Application Support/Epic/UnrealBuildTool/Log_UHT.txt" -installed
2022-03-21 17:05:09.060 UnrealHeaderTool[2888:49018] [UE4] Looking for binary: …/…/…/Engine/Programs/UnrealHeaderTool/Config/BinaryConfig.ini
LogInit: Display: Loading text-based GConfig…
Reflection code generated for MyProject2123Editor in 3.8529199 seconds
@progress pop
Building MyProject2123Editor…
Performing 7 actions (5 in parallel)
[1/7] Compile SharedPCH.Engine.ShadowErrors.h
In file included from /Users/sagardwevedi/Documents/Unreal Projects/MyProject2123/Intermediate/Build/Mac/x86_64/MyProject2123Editor/Development/Engine/SharedPCH.Engine.ShadowErrors.h:284:
In file included from /Users/Shared/Epic Games/UE_4.27/Engine/Source/Runtime/Engine/Public/EngineSharedPCH.h:572:
/Users/Shared/Epic Games/UE_4.27/Engine/Source/Runtime/Engine/Classes/Materials/Material.h:1279:26: error: variable ‘LayerNames’ set but not used [-Werror,-Wunused-but-set-variable]
const TArray* LayerNames = &LayersExpression->GetLayerNames();
^
1 error generated.

2 Likes

Found this LayerNames error bricking my Mac projects - #3 by benvillalobos

Got the same error after Xcode update, I tried to

  • clean project, remove build, Intermediate, etc folders
  • reinstall Xcode additional components
    Nothing helped me

My friend has the same compile error on Mac, XCode 13.3 and UE 4.27.2… I checked the source code and it appears that a variable is initialized but not used. This raises the error. What we did was to comment out the lines 1279 and 1293 in Engine/Source/Runtime/Engine/Classes/Materials/Material.h file as the assigned variable is never used in the code.

const TArray<UMaterialFunctionInterface*>* Layers = &LayersExpression->GetLayers();
const TArray<UMaterialFunctionInterface*>* Blends = &LayersExpression->GetBlends();
#if WITH_EDITOR
// ********** COMMENT OUT THIS LINE **********
//const TArray<FText>* LayerNames = &LayersExpression->GetLayerNames();
#endif
	
// Handle function overrides when searching for parameters
if (MaterialLayersParameters)
{
	const FName& ParameterName = LayersExpression->ParameterName;
	for (const FStaticMaterialLayersParameter& LayersParameter : *MaterialLayersParameters)
	{
		if (LayersParameter.ParameterInfo.Name == ParameterName)
		{
			Layers = &LayersParameter.Value.Layers;
			Blends = &LayersParameter.Value.Blends;
#if WITH_EDITOR
			// ********** COMMENT OUT THIS LINE **********
			// LayerNames = &LayersParameter.Value.LayerNames;
#endif
			break;
		}
4 Likes

Basically we need to downgrade the Xcode to 13.2.1 and all problems will be resolved, mine working fine. also remember to place Xcode in Application folder of the mac otherwise unreal won’t be able to find the location of xcode

1 Like

Thank you, this fix my project!!

Thanks this worked for me!