How to solve this problem "No compiler was found in order to use C++ template install Xcode"

I’m using Ue4.25.4 in M1 Mac with Big Sur 11.3.1 and Xcode 12.5. But when I try to create new C++ project it gives me this error how to solve this problem. Initially it worked fine and I used VSCode as C++ editor . But later I used ccl cleaner and avg cleaner to clear the cache after which it started showing me this error. I have command line tools installed along with Xcode as I use it for iOS development. I have even tried reinstalling ue4 and Xcode still no luck. Any way to fix this problem. UE4 in Mac is becoming worst every year after new Mac OS release.