How to disassociate a single app (e.g., Xcode) from all file types it’s mapped to

filexcode

Every time I get a machine that I install Xcode on, it associates itself with all kinds of filetypes. E.g., .xml, .rb, even .java! It's such a nuisance to have to re-associate those file extensions individually. If I want to open Xcode, I'll open Xcode, but I never want to open Xcode by double-clicking on a script or using open.

Is there any way to globally disassociate Xcode from all file types? More generally, is there any way to do this for any app (e.g., QuickTime)?

PS: I know about How to Change File Type Associations? but this aims at changing one specific association, not disabling them all at once.

Best Answer

You could delete the CFBundleDocumentTypes array in the Info.plist, but it is also used to define file types like xcodeproj. It would also invalidate the code signature (so you'd have to enter a password to access keychains), and the changes might get overridden by updates. Some applications like TextEdit crash on launch if the Info.plist is modified.

To update the Launch Services database, run /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -R -f /Applications/Application.app/.

You could also unregister the application by running lsregister -u -R -f /Applications/Application.app/, but I don't know if it would get registered again at some point. It would also remove the icons of file types defined by the application.

If you are looking for a faster way to change default applications, take a look at duti. I have published my configuration file (which includes common code and video file types) here.