I solved this problem by opening the Terminal and running the command:
xcode-select --install
I fixed this problem by reinstalling Xcode.