Stop Xcode from Hijacking my File Associations

Absolutely there is!
Unfortunately because Xcode is installed through the Mac App Store, we are unable to control / prevent the change from occurring in the first place. The automated installation takes care of that for us.

How to Change the Default Programs
Luckily there is an easy fix to resolving the issue and reversing the change. The only caveat of which is the fact that this is done on an extension-based level.

  1. Go to any file whose extension you don't want to open with Xcode (e.g. my file.java).
  2. Right click on it, select Get Info (or CMD I).
  3. Under Open With, select your editor for that extension.
  4. Click Change All to make the change global across all files of this type.

I believe some IDEs or even individual Text editors will ask if you would like to associate them with the most common formats for software development - with Xcode that's a little less optional. Anyway, hope that helps, let me know if it did and how you make out. I'd be interested in following up with you on this.


The best workaround I've found is to install the Xcode CLI and NEVER INSTALL the Xcode GUI. As OP says, the GUI/IDE aggressively accrues responsibilities and I never worked out how to stop it.

Use xcode-select --install in terminal to get the CLI. This solves Xcode dependency for (eg.) Homebrew and you can subsequently forget about Xcode.


The other answers didn't help me, because I still need the GUI of Xcode. Therefore, here is a different approach:

You can use SwiftDefaultApps to override the default apps. You can find it on GitHub: https://github.com/Lord-Kamina/SwiftDefaultApps

After the installation you will find in the system preferences the new item SwiftDefaultApps. In the tab "Uniform Type Identifiers" you can change the editor for the type "public.php-script". You can even overwrite the viewer for the preview.

SwiftDefaultApps Screenshot PHP