I had the same issue. Apparently installing Homebrew can break something and make Unreal think you’ve moved Xcode. All Unreal wants you to do is point to the proper location, and that’s what the command does. (If you HAD moved the location, you would simply change the “Applications/Xcode.app” to your actual location. If you haven’t changed the location, simply leave it as it is:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Cheers!