Error: lambda capture 'class-name' is not required to be captured for this use [-Werror,-Wunused-lambda-capture]

It was working fine before I updated my Xcode to 9.3. Now even I moved back to Xcode 9.2 but still getting this error

LogPlayLevel: In file included from
/Work/UnrealEngine/Engine/Intermediate/Build/Mac/UnrealHeaderTool/Development/Core/Module.Core.2_of_8.cpp:27:
LogPlayLevel:
/Work/UnrealEngine/Engine/Source/Runtime/Core/Private/HAL/UnrealMemory.cpp:279:13:
error: lambda capture ‘ArraySize’ is
not required to be captured for this
use [-Werror,-Wunused-lambda-capture]
LogPlayLevel:
Pointer, ArraySize LogPlayLevel:
^ LogPlayLevel: In file included
from
/Work/UnrealEngine/Engine/Intermediate/Build/Mac/UnrealHeaderTool/Development/Core/Module.Core.3_of_8.cpp:30:
LogPlayLevel:
/Work/UnrealEngine/Engine/Source/Runtime/Core/Private/Internationalization/TextLocalizationManager.cpp:219:36:
error: lambda capture
‘ShouldLoadEditor’ is not required to
be captured for this use
[-Werror,-Wunused-lambda-capture]
LogPlayLevel: auto
ValidateRequestedCulture =
[ShouldLoadEditor, ShouldLoadGame,
&I18N](const FString&
InRequestedCulture, const FString&
InFallbackCulture, const TCHAR*
InLogDesc, const bool
bWarnIfNotExactMatch) → FString
LogPlayLevel:
^ LogPlayLevel: In file included
from
/Work/UnrealEngine/Engine/Intermediate/Build/Mac/UnrealHeaderTool/Development/Core/Module.Core.8_of_8.cpp:24:
LogPlayLevel: In file included from
/Work/UnrealEngine/Engine/Source/Runtime/Core/Private/Tests/Misc/TypeContainerTest.cpp:11:
LogPlayLevel:
Runtime/Core/Public/Misc/TypeContainer.h:245:7:
error: lambda capture ‘this’ is not
used [-Werror,-Wunused-lambda-capture]
LogPlayLevel:
this → TSharedPtr {
LogPlayLevel:
^ LogPlayLevel:
/Work/UnrealEngine/Engine/Source/Runtime/Core/Private/Tests/Misc/TypeContainerTest.cpp:109:14:
note: in instantiation of function
template specialization
‘TTypeContainer::RegisterClass FBanana>’ requested here LogPlayLevel:
Container.RegisterClass FBanana>(ETypeContainerScope::Instance);
LogPlayLevel:
^ LogPlayLevel: In file included
from
/Work/UnrealEngine/Engine/Intermediate/Build/Mac/UnrealHeaderTool/Development/Core/Module.Core.8_of_8.cpp:24:
LogPlayLevel: In file included from
/Work/UnrealEngine/Engine/Source/Runtime/Core/Private/Tests/Misc/TypeContainerTest.cpp:11:
LogPlayLevel:
Runtime/Core/Public/Misc/TypeContainer.h:255:7:
error: lambda capture ‘this’ is not
used [-Werror,-Wunused-lambda-capture]
LogPlayLevel:
this → TSharedPtr {
LogPlayLevel:
^ LogPlayLevel:
Runtime/Core/Public/Misc/TypeContainer.h:245:7:
error: lambda capture ‘this’ is not
used [-Werror,-Wunused-lambda-capture]
LogPlayLevel:
this → TSharedPtr {
LogPlayLevel:
^ LogPlayLevel:
/Work/UnrealEngine/Engine/Source/Runtime/Core/Private/Tests/Misc/TypeContainerTest.cpp:110:14:
note: in instantiation of function
template specialization
‘TTypeContainer::RegisterClass FStrawberry>’ requested here
LogPlayLevel:
Container.RegisterClass FStrawberry>(ETypeContainerScope::Instance);
LogPlayLevel:
^ LogPlayLevel: In file included
from
/Work/UnrealEngine/Engine/Intermediate/Build/Mac/UnrealHeaderTool/Development/Core/Module.Core.8_of_8.cpp:24:
LogPlayLevel: In file included from
/Work/UnrealEngine/Engine/Source/Runtime/Core/Private/Tests/Misc/TypeContainerTest.cpp:11:
LogPlayLevel:
Runtime/Core/Public/Misc/TypeContainer.h:255:7:
error: lambda capture ‘this’ is not
used [-Werror,-Wunused-lambda-capture]
LogPlayLevel:
this → TSharedPtr {
LogPlayLevel:
^ LogPlayLevel:
Runtime/Core/Public/Misc/TypeContainer.h:245:7:
error: lambda capture ‘this’ is not
used [-Werror,-Wunused-lambda-capture]
LogPlayLevel:
this → TSharedPtr {
LogPlayLevel:
^ LogPlayLevel:
/Work/UnrealEngine/Engine/Source/Runtime/Core/Private/Tests/Misc/TypeContainerTest.cpp:126:14:
note: in instantiation of function
template specialization
‘TTypeContainer::RegisterClass FBanana>’ requested here LogPlayLevel:
Container.RegisterClass FBanana>(ETypeContainerScope::Thread);
LogPlayLevel:
^ LogPlayLevel: In file included
from
/Work/UnrealEngine/Engine/Intermediate/Build/Mac/UnrealHeaderTool/Development/Core/Module.Core.8_of_8.cpp:24:
LogPlayLevel: In file included from
/Work/UnrealEngine/Engine/Source/Runtime/Core/Private/Tests/Misc/TypeContainerTest.cpp:11:
LogPlayLevel:
Runtime/Core/Public/Misc/TypeContainer.h:255:7:
error: lambda capture ‘this’ is not
used [-Werror,-Wunused-lambda-capture]
LogPlayLevel:
this → TSharedPtr {
LogPlayLevel:
^ LogPlayLevel: 1 error generated.
LogPlayLevel:
Runtime/Core/Public/Misc/TypeContainer.h:245:7:
error: lambda capture ‘this’ is not
used [-Werror,-Wunused-lambda-capture]
LogPlayLevel:
this → TSharedPtr {
LogPlayLevel:
^ LogPlayLevel:
/Work/UnrealEngine/Engine/Source/Runtime/Core/Private/Tests/Misc/TypeContainerTest.cpp:127:14:
note: in instantiation of function
template specialization
‘TTypeContainer::RegisterClass FStrawberry>’ requested here
LogPlayLevel:
Container.RegisterClass FStrawberry>(ETypeContainerScope::Instance);
LogPlayLevel:
^ LogPlayLevel: In file included
from
/Work/UnrealEngine/Engine/Intermediate/Build/Mac/UnrealHeaderTool/Development/Core/Module.Core.8_of_8.cpp:24:
LogPlayLevel: In file included from
/Work/UnrealEngine/Engine/Source/Runtime/Core/Private/Tests/Misc/TypeContainerTest.cpp:11:
LogPlayLevel:
Runtime/Core/Public/Misc/TypeContainer.h:255:7:
error: lambda capture ‘this’ is not
used [-Werror,-Wunused-lambda-capture]
LogPlayLevel:
this → TSharedPtr {
LogPlayLevel:
^ LogPlayLevel: 8 errors generated.
LogPlayLevel: 1 error generated.
LogPlayLevel: In file included from
/Work/UnrealEngine/Engine/Intermediate/Build/Mac/UnrealHeaderTool/Development/UnrealHeaderTool/Module.UnrealHeaderTool.cpp:2:
LogPlayLevel: In file included from
/Work/UnrealEngine/Engine/Source/Programs/UnrealHeaderTool/Private/BaseParser.cpp:8:
LogPlayLevel: In file included from
Programs/UnrealHeaderTool/Private/ParserHelper.h:9:
LogPlayLevel: In file included from
Runtime/CoreUObject/Public/UObject/TextProperty.h:7:
LogPlayLevel:
Runtime/CoreUObject/Public/UObject/UnrealType.h:3285:37:
error: lambda capture
‘LocalMapLayoutForCapture’ is not used
[-Werror,-Wunused-lambda-capture]
LogPlayLevel:
[LocalKeyPropForCapture, KeyPtr,
LocalMapLayoutForCapture](void*
NewElementKey) LogPlayLevel:
^ LogPlayLevel:
Runtime/CoreUObject/Public/UObject/UnrealType.h:3298:41:
error: lambda capture
‘LocalMapLayoutForCapture’ is not used
[-Werror,-Wunused-lambda-capture]
LogPlayLevel:
[LocalValuePropForCapture, ValuePtr,
LocalMapLayoutForCapture](void*
NewElementValue) LogPlayLevel:
^ LogPlayLevel:
Runtime/CoreUObject/Public/UObject/UnrealType.h:3808:47:
error: lambda capture
‘LocalSetLayoutForCapture’ is not used
[-Werror,-Wunused-lambda-capture]
LogPlayLevel:
[LocalElementPropForCapture,
ElementToAdd,
LocalSetLayoutForCapture](void*
NewElement) LogPlayLevel:
^ LogPlayLevel: In file included
from
/Work/UnrealEngine/Engine/Intermediate/Build/Mac/UnrealHeaderTool/Development/CoreUObject/PCH.CoreUObject.h:48:
LogPlayLevel: In file included from
/Work/UnrealEngine/Engine/Source/Runtime/CoreUObject/Private/CoreUObjectPrivatePCH.h:236:
LogPlayLevel:
Runtime/CoreUObject/Public/UObject/UnrealType.h:3285:37:
error: lambda capture
‘LocalMapLayoutForCapture’ is not used
[-Werror,-Wunused-lambda-capture]
LogPlayLevel:
[LocalKeyPropForCapture, KeyPtr,
LocalMapLayoutForCapture](void*
NewElementKey) LogPlayLevel:
^ LogPlayLevel:
Runtime/CoreUObject/Public/UObject/UnrealType.h:3298:41:
error: lambda capture
‘LocalMapLayoutForCapture’ is not used
[-Werror,-Wunused-lambda-capture]
LogPlayLevel:
[LocalValuePropForCapture, ValuePtr,
LocalMapLayoutForCapture](void*
NewElementValue) LogPlayLevel:
^ LogPlayLevel:
Runtime/CoreUObject/Public/UObject/UnrealType.h:3808:47:
error: lambda capture
‘LocalSetLayoutForCapture’ is not used
[-Werror,-Wunused-lambda-capture]
LogPlayLevel:
[LocalElementPropForCapture,
ElementToAdd,
LocalSetLayoutForCapture](void*
NewElement) LogPlayLevel:
^ LogPlayLevel: 3 errors generated.
LogPlayLevel: 3 errors generated.
LogPlayLevel: Total build time:
14.56 seconds (Local executor: 7.72 seconds) LogPlayLevel: Error:
UnrealHeaderTool failed for target
‘UnrealFramework’ (platform: IOS,
module info:
/Work/NewUnrealFramework/Intermediate/Build/IOS/UnrealFramework/Development/UnrealFramework.uhtmanifest,
exit code: OtherCompilationError (5)).
LogPlayLevel: Took 29.583506s to run
mono, ExitCode=5 LogPlayLevel: ERROR:
Command failed (Result:5):
/Work/UnrealEngine/Engine/Binaries/DotNET/UnrealBuildTool.exe
UnrealFramework IOS Development
-Project=/Work/NewUnrealFramework/UnrealFramework.uproject
/Work/NewUnrealFramework/UnrealFramework.uproject
-NoUBTMakefiles -remoteini="/Work/NewUnrealFramework" -skipdeploy -ini:Game:[/Script/UnrealEd.ProjectPackag
ingSettings]:BlueprintNativizationMethod=Disabled
-noxge -nocreatestub -NoHotReload -ignorejunk. See logfile for details: ‘UnrealBuildTool-2018.04.05-12.24.55.txt’
LogPlayLevel: (see
/Users/umair/Library/Logs/Unreal
Engine/LocalBuildLogs/UAT_Log.txt for
full exception trace) LogPlayLevel:
AutomationTool exiting with ExitCode=5
(5) LogPlayLevel: Completed Launch On
Stage: Build Task, Time: 42.002421
LogPlayLevel: RunUAT ERROR:
AutomationTool was unable to run
successfully. PackagingResults: Error:
Launch failed! Unknown Error

I also run into this errors generated from [-Werror,-Wunused-lambda-capture] setting using Xcode 9.3 and was able to work around it with downgrading to Xcode 9.0.

You’ll need to backport this fix from 4.19:
https://github.com/EpicGames/UnrealEngine/blob/8e4560b8c22b309e73ff0ce90377742c3dfe13cc/Engine/Source/Runtime/Core/Public/IOS/IOSPlatformCompilerPreSetup.h#L54-L57

@iktomi
Thanks the clang setting for the lambda is working.
We need to add this in IOSPlatformCompilerPreSetup.h as well as MacPlatformCompilerPreSetup.h
Just add this at the end of the file:

// Apple LLVM 9.1.0 (Xcode 9.3)
#if (__clang_major__ > 9) || (__clang_major__ == 9 && __clang_minor__ >= 1)
#pragma clang diagnostic ignored "-Wunused-lambda-capture"
#endif