43

I typically associate certain file types with certain editors and IDEs. You know R with RStudio, Java with JetBrains, and all the other goodies with Sublime Text.

But every time I install an Xcode update, Xcode takes over every code-related extension imaginable, and I have to associate my files manually.

Is there anyway to prevent Xcode from taking over my file associations?

3
  • 5
    ^^THIS. The best workaround I've found is to never install the sodding GUI. Use xcode-select --install in terminal Feb 7, 2020 at 15:32
  • We might be able to edit xcode's Info.plist file to remove any CFBundleTypeExtensions that we don't want. (article) But it might get wiped every time xcode updates :/ Leaving as a comment in case this turns out useful but I haven't been able to try it yet.
    – mrgnw
    Apr 13, 2020 at 15:01
  • I hope someone find a reliable answer to this, once terminal command to fix all.
    – sorin
    Jun 10, 2020 at 8:01

4 Answers 4

27

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.

6
  • 12
    I already know that I can change the extensions manually... that's how I did it in the first place. I just don't want Xcode to be able to hijack my file associations on every update.
    – fny
    Mar 1, 2018 at 4:13
  • 1
    @fny Were you able to make any progress on this? I feel that at this point my answer is the only way to resolve the extension hijacking so I am also keen to know if you have found alternative solution in the meantime.
    – ProGrammer
    Mar 9, 2018 at 10:06
  • 1
    Nope haven't had time to figure anything out!
    – fny
    Mar 13, 2018 at 0:46
  • 1
    I love how no one ever reads these questions properly (of which there are numerous examples on the web) and says "just use the 'change all' option", not realising that that is exactly what people HAVE been doing....if it worked, why would they still be asking the question?! ;-) Jan 25, 2021 at 16:38
  • I have been annoyed by this for too long... I couldn't understand why the "open with" dialog and checking the "always open with' button never worked... this fixed it 🎉🎉🎉🎉 Apr 15, 2022 at 14:00
8

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.

5

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

1

duti will help, check this Set vscode as the default for text files on mac

brew install duti
duti -s com.microsoft.VSCode public.json all
duti -s com.microsoft.VSCode public.plain-text all
duti -s com.microsoft.VSCode public.python-script all
duti -s com.microsoft.VSCode public.shell-script all
duti -s com.microsoft.VSCode public.source-code all
duti -s com.microsoft.VSCode public.text all
duti -s com.microsoft.VSCode public.unix-executable all
duti -s com.microsoft.VSCode .md all
1
  • Hello, Cosmore. This is considered a "link-only" answer. It would be helpful for future visitors to this question if you would edit in a summary of that page. Links can become broken or outdated so a summary would still provide the necessary information.
    – agarza
    Jul 15, 2022 at 17:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .