I can't build a c++ program on my Mac with Xcode

when I want to build a program there has an error

Running Mono…

Setting up Mono
/Users/Shared/Epic Games/UE_4.19/Engine /Users/Shared/Epic Games/UE_4.19/Engine/Binaries/Mac
Discovering modules, targets and source code for project…
Triggered an exception while looking for SDK directory in Xcode.app
System.IO.DirectoryNotFoundException: Directory ‘/Library/Developer/CommandLineTools/Platforms/MacOSX.platform/Developer/SDKs’ not found.
at System.IO.Directory.ValidateDirectoryListing (System.String path, System.String searchPattern, System.Boolean& stop) [0x00000] in :0
at System.IO.Directory.GetFileSystemEntries (System.String path, System.String searchPattern, FileAttributes mask, FileAttributes attrs) [0x00000] in :0
at System.IO.Directory.GetDirectories (System.String path, System.String searchPattern) [0x00000] in :0
at System.IO.Directory.GetDirectories (System.String path) [0x00000] in :0
at UnrealBuildTool.AppleToolChainSettings.SelectSDK (System.String BaseSDKDir, System.String OSPrefix, System.String& PlatformSDKVersion, Boolean bVerbose) [0x00000] in :0
WARNING: Exception while generating include data for UE4Editor: Invalid SDK MacOSX.sdk, not found in /Library/Developer/CommandLineTools/Platforms/MacOSX.platform/Developer/SDKs
Generating data for project indexing… 0%@progress ‘Generating data for project indexing…’ 50%
WARNING: Exception while generating include data for cppEditor: Invalid SDK MacOSX.sdk, not found in /Library/Developer/CommandLineTools/Platforms/MacOSX.platform/Developer/SDKs
Generating data for project indexing… 50%@progress ‘Generating data for project indexing…’ 100%
ERROR: UnrealBuildTool Exception: Invalid SDK MacOSX.sdk, not found in /Library/Developer/CommandLineTools/Platforms/MacOSX.platform/Developer/SDKs

how could I do

Directory ‘/Library/Developer/CommandLineTools/Platforms/MacOSX.platform/Developer/SDKs’ not found

The error message clearly states that you don’t have the Xcode Command Line Tools installed. You can find them here.

Alternatively you could run the following command in your terminal of choice, which will trigger a pop-up requesting you to install them;

xcode-select --install

I had a similar problem. Tried to install command line tools, but the path indicated still didn’t exist and tried to manually create the path to the SDK’s without success.

In Terminal I checked the path to Xcode:

$ xcode-select -p

/Library/Developer/CommandLineTools (result to existing Xcode path)

then changed it to point to the Xcode application in the applications folder:

$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

So far seems to have resolved the issue.