xCode errors when building source engine - worked fine before xCode update

All of a sudden I’m getting errors in my source build of UE 4.21.2 from GitHub when building on macOS with xCode.

The main error I’m getting is “Local variable ‘varname’ will be copied dispite being returned by name”
Showing up in:

  • CodeGenerator.cpp line 2593
  • UnrealSourceFIle.cpp line 49
  • Player.cpp line 67
  • UnrealExplorer.cpp line 872, 892
  • TimerManager.cpp line 45
  • Messages.h line 22, 50, 82, 118, 158

Also getting the error “Assigning field to itself”

  • NiagraScriptVIewModel.cpp line 301

And finally the error “Explicityly assigning value of variable of type ‘FText’ to itself”

  • SBlueprintPalette.cpp line 323

This build has previously worked just fine. I noticed xCode was updated on 4/6, so it probably started then. I’m guessing that some llvm update is treating things slightly differently.

The workarounds to get this stuff working are not too bad, the problem is as I fix them, more and more of the same types of errors pop up. I’m wondering if theres something in Unreal’s settings that can fix them. I think they can all be cleared if treating errors as warnings was false, but some googleing didn’t reveal a way to do this.

So it looks like there is not a configurable way to disable warnings as errors. I found in MacToolChain.cs that warnings as errors are just hard coded into the compiler settings. I could disable that, but instead I’m going to try adding my particular issues to the list of disabled clang diagnostic warnings in ApplePlatformCompilerPreSetup.h as that seems to be the designed way to do it.

Adding the following fixed the errors I was running into.

ApplePlatformCompilerPreSetup.h



#pragma clang diagnostic ignored "-Wreturn-std-move"
#pragma clang diagnostic ignored "-Wreturn-std-move-in-c++11"
#pragma clang diagnostic ignored "-Wself-assign"
#pragma clang diagnostic ignored "-Wself-assign-field"