How can I completely uninstall Xcode in macOS Mojave 10.14?

After upgrading to macOS Mojave 10.14, Xcode was no longer updating correctly and my build process was reporting that stdlib.h was missing. Thus, I attempted to uninstall it so I could reinstall it after.

However, after removing it via the (x) button displayed on the Xcode app icon in Launchpad, the app was still in /Applications directory. So I deleted it from there as well.

However, the Mac App Store is still showing the option to update Xcode as if it were installed (and clicking the button resulted in a loading animation being displayed for half a second and then the update button again). I have also removed all the various folder listed here:

  • https://stackoverflow.com/a/53575585/1824538

as well as followed the instructions to empty the Mac App Store cache provided here:

  • How to fix / Reset App Store app on Mac OSX - El Capitan

and here:

  • How to remove deleted app from OS X update list?

So far, nothing has changed the fact that the Mac App Store thinks I should update instead of install.

Is there anything else to do to get the Mac App Store to reinstall Xcode?

If it's easier, I'd be content with installing LLVM via Homebrew without messing things up. I don't really need Xcode itself, only the build tools.

xcode-select --install behaves similarly to the Mac App Store (namely claiming the tools are already installed or producing a non-working installation if I remove the CommandLineTools directories in the different Libraries).

EDIT: after some more back-and-forth I managed to get the Command Line Tools working via xcode-select --install. However, I'm still left with the update notification for Xcode in the Mac App Store.


Solution 1:

What finally solved the problem for me was to download and install the Command Line Tools as well as Xcode (in that order) from the Apple developer site. After the next reboot, the Mac App Store recognised Xcode as not installed and all standard libraries and compilers were available again (which was not quite the case with Command Line Tools only).

Solution 2:

You might need to forget the package. :EDIT

Every package installed via Apple tools is recorded.

You can use pkgutil to find out which files were installed.

man pkgutil

pkgutil --pkgs #the packages installed on the system

pkgutil --files package-id # installed files

Remove these files. Job's not quite done, though. Depending on your use case, you might want all knowledge of this install to be removed.

pkgutil --forget package-id # this never happened.

Solution 3:

I just reinstalled Xcode yesterday for an issue and I was encountering something similar. Finally, I

  • removed Xcode (just drag to trash and empty it)
  • rebooted machine
  • installed Xcode from store
  • installed command-line tools
  • rebooted

Stuff seems to work once again.