Xcode sets itself als default application to open markdown files even if prompted not to, apparently at login.

After Xcode broke my git installation for intractable reasons, removing the present git executable from my PATH (there are StackOverflow posts about this dating back to 2017!), which took me hours to figure out, I now have another problem caused by Xcode.


Xcode sets itself as the default application to open a bunch of file types, most importantly for me:

JSON and Markdown.


I repeatedly right-clicked markdown files in Finder, selected "Open with...", then changed "Recommended applications" to "All applications", selected QLMarkdown, which is the application I want to use and which was grayed out for intractable reasons as well, then I checked the box "Always open with".


This works for one session if I'm lucky, but after closing the lid of my MacBook and opening it again the default is already reset to Xcode.


This is not acceptable:

Xcode is a dog-slow application even on an M1 Pro with 32GB of RAM and is absolutely unsuitable to open Markdown files for viewing because it takes ages to start and uses a lot of battery.


I want to keep my defaults and I would very much like Xcode to not break my system settings, as it is a required application to do lots of stuff on macOS.



As far as I am concerned, this is clearly a bug, not even a bug in Xcode but a bug that makes Xcode break other applications, which should be fixed with high priority. Would send this to feedback but first:


Does anyone know a workaround or possible cause for this?


I read something about reinstalling Xcode but honestly that's not something I am willing to invest time in.

I'd prefer to remove it altogether and try to work around that, but it seems Apple wants to make this hard for developers of even non iOS-/macOS applications.


Thanks

MacBook Pro 14″

Posted on Apr 5, 2023 10:17 AM

Reply
Question marked as Top-ranking reply

Posted on Jun 9, 2024 9:32 PM

TLDR: you must launch Finder, go to File > Get Info, then select a markdown file to permanently set the app of your choice as the file association.


  • Bringing up the file association dialog when you open a particular file will not work.
  • You do not need to install or reinstall Xcode, git, or anything else.


A very non-intuitive Mac/Finder behavior that took me months to figure out. Thanks @moritz116 for drawing attention to this.

Similar questions

16 replies
Question marked as Top-ranking reply

Jun 9, 2024 9:32 PM in response to moritz116

TLDR: you must launch Finder, go to File > Get Info, then select a markdown file to permanently set the app of your choice as the file association.


  • Bringing up the file association dialog when you open a particular file will not work.
  • You do not need to install or reinstall Xcode, git, or anything else.


A very non-intuitive Mac/Finder behavior that took me months to figure out. Thanks @moritz116 for drawing attention to this.

Apr 5, 2023 11:59 AM in response to moritz116

moritz116 wrote:

I understand that my post had a frustrated tone and this is a support forum, but if you can't offer a solution, why patronise me?

I definitively solved your question:


If you want to change the association for all files, you need to use Finder's "Get Info".

Select one Markdown file in the Finder. Choose Get Info from the Finder's File menu. Change the associated application. Then click the "Change all" button to apply the change to all documents. Repeat for a JSON file.


By the way, how do I leave a block quote at the end of my post here? Neither return nor arrow-down work (Safari on latest macOS Ventura).

Do you mean leave as in "add" or leave as in "depart"? To add a block quote, click the block quote tool in the toolbar of the editing panel. To leave a block quote, click outside of it. The current forum software does have a bug that will tend to add an orphan block quote to the end if you try to get fancy.

Regarding the contents of the quote, I assume that switching from Xcode to Xcode CLI-only tools is the same thing as a reinstall?

I'm not sure what you are asking. I'm also not sure what you have already done. That's why I suggested setting up the entire system again. I can tell you that the system is not designed to switch back and forth between the Command Line tools and Xcode. Install one or the other.


Perhaps the best way to think of it is to remember that Xcode is strictly a cross-platform IDE for building and distributing iOS apps. It does Mac apps too, but only as an afterthought. You can have as many versions of Xcode installed as you want in case you had really specific needs.


The Command Line tools, however, are designed for building and using tools on your own Mac, not for distribution. If you need to distribute anything, then you may need the full Xcode toolset, even if you don't use the IDE. I'm not entirely certain about their capabilities because I never use the Command Line tools.


I finally found the solution for my problem, surprise: on a variant of StackOverflow:

https://apple.stackexchange.com/questions/316880/stop-xcode-from-hijacking-my-file-associations

Of course you can always redefine things to not be a problem instead of trying to answer, same thing as here:
How do I remove a best answer in here? - Apple Community

I would like to mark this (my own) reply as best answer, as the linked thread answers the question and the reason for my problem is simple: Xcode breaks the expected functionality of "Always open with" in hard-to-predict ways.

You can't change your "Helpful" or "Best Answer" selections. But that's good in this case.


I strongly recommend you more closely review my advice about not taking shortcuts. The "solution" from that last Stack Overflow answer is actually the same solution that I gave you above. I looks like you simply aren't paying attention to what I told you, and the specifics of what that Stack Overflow question and answer are telling you. That is different that your original question in a very significant way. In this domain, those details are very important. Stop skimming.


Apr 5, 2023 10:54 AM in response to moritz116

moritz116 wrote:

After Xcode broke my git installation for intractable reasons

Xcode includes git. There is nothing else you need to download.

(there are StackOverflow posts about this dating back to 2017!)

Don't believe what you read on the internet. It's wrong, especially Stack Overflow.

I repeatedly right-clicked markdown files in Finder, selected "Open with...", then changed "Recommended applications" to "All applications", selected QLMarkdown, which is the application I want to use and which was grayed out for intractable reasons as well, then I checked the box "Always open with".

That's not how you do it. What you are describing is the procedure to override the system's app/document association for a single file. If you want to change the association for all files, you need to use Finder's "Get Info".


Select one Markdown file in the Finder. Choose Get Info from the Finder's File menu. Change the associated application. Then click the "Change all" button to apply the change to all documents. Repeat for a JSON file.

Xcode is a dog-slow application even on an M1 Pro with 32GB of RAM and is absolutely unsuitable to open Markdown files for viewing because it takes ages to start and uses a lot of battery.

Xcode is a very intensive app. I strongly recommend keeping the power connected if you have power available. Apple devices are optimized for battery life over performance. Trying to run Xcode on battery will not just drain your battery, it also makes Xcode run slower.

I read something about reinstalling Xcode

Again, stop reading things on the internet. They are clearly leading you astray. The internet isn't true.

I'd prefer to remove it altogether and try to work around that, but it seems Apple wants to make this hard for developers of even non iOS-/macOS applications.

Xcode is designed exclusively for developers of iOS and macOS applications. You don't need it for anything else. A few oddballs like me may use it for website development, but otherwise, I just don't know what you are doing there.


It sounds like the Command Line tools would be a better option for you. They include git and all of the other command line tools you would need, but not Xcode.

Apr 5, 2023 11:43 AM in response to moritz116

I finally found the solution for my problem, surprise: on a variant of StackOverflow:


https://apple.stackexchange.com/questions/316880/stop-xcode-from-hijacking-my-file-associations


Of course one can always argue what behavior is expected, but I was not prompted if I want Xcode to seemingly irreversibly trash multiple settings on my system when installing it.

Now I have this problem:

How do I remove a best answer in here? - Apple Community


Because I would like to mark this (my own) reply as best answer.

The linked thread on StackExchange clearly answers the question and the reason for my problem is simple: Xcode breaks the expected functionality of "Always open with" in hard-to-predict ways.


The problem and solution apparently haven't changed since the time that Q&A thread was posted.

Apr 5, 2023 10:56 AM in response to moritz116

moritz116 wrote:

Is there some tool to revert all configuration changes made by XCode and uninstall it along with all the libraries, interpreters and tools it includes?

Xcode is a self-contained app. If you don't want it, just drag it to the trash. You might want to remove the "Developer" folder in your Library folder too. If you aren't using Xcode, then you won't need any of that.

Apr 5, 2023 11:41 AM in response to moritz116

moritz116 wrote:

I encountered this problem myself after installing Xcode as recommended for trying to follow this guide:

Running GUI Linux in a virtual machine on a Mac | Apple Developer Documentation

That's not a guide. It is sample code to accompany the documentation for the Virtualization framework.

The problem did not have anything to do with me following SO instructions or something along these lines.

The vast majority of problems reported by people doing anything more difficult than running basic apps comes from following instructions on the internet. That's just something I regularly throw in to any response where I suspect someone is heading down a bad path. Online resources can be useful to learn about the existence of features or capabilities. But users in these more advanced domains need to develop their own competence in these areas before trying to deploy them, even on their own computers. That advice applies equally to Apple's sample code and Stack Overflow.

I see Xcode might contain another git executable, but that was completely irrelevant to my problem – it broke my working git installation and git wasn't usable in the default shell or other tools anymore.
Must have been be some kind of misconfiguration on my side then, OTOH: that's why I searched StackOverflow in the first place.

Not really. That's rabbit hole thinking. If you had wanted to install your own copy of git, you could certainly do so and it would work fine. Xcode would not interfere as long as you set it up properly. These things are possible and aren't difficult to do. You just don't need that capability right now.

Does switching to Xcode CLI Tools require reinstalling Xcode?

No. The Command Line tools are completely separate from Xcode. They provide git, clang, gcc, make, etc. - pretty much everything you would need to develop software or use Unix-style tools and scripts. They are to be used instead of Xcode.


If you sit down to a brand new Mac and just type "git", or anything of that ilk, that will prompt you to install the Command Line tools.


However, use of Xcode can make some significant low-level changes to a system. Running Xcode turns a Mac into a development machine. This makes it practically useless for testing the apps a developer would be building. This can be true for the Command Lines tools to a certain extent too. You simply aren't dealing with the same system that other people have. If your work involves exporting any "products" of any kind to other people's computers, then you will need to make sure to test them on a pristine Mac that has never been used in this fashion.


I don't know if you are doing any of that. I'm just throwing it out to avoid problems later on. If you really need to work on Linux, then you should seriously consider wiping the Mac and staying in the Linux environment using UTM or similar. (Unfortunately, Apple's new Virtualization framework has wrecked the Mac VM market. Some of the great, inexpensive tools that made the intel Macs so useful are now abandoned. Technically, the M1 Macs are more capable VM machines than ever. It's just the market that's now dead.)


If you want to leverage the power of the Mac to support and accelerate the work you are doing on Linux, then you should proceed more carefully. The Mac isn't Linux. It isn't even BSD. There is one way to make it work and that way is not documented. It is, essentially, install software correctly and don't take shortcuts. Seems like a simple idea. Haven't found anyone yet who has taken that approach.

Apr 5, 2023 10:26 AM in response to moritz116

Just tested this again.

To add to the issue:


Even without closing the lid or logging out in between, the setting does not persist for newly downloaded files.

Weirdly, not even the warning about "opening untrusted files" is shown, it just opens the "untrusted markdown files" in Xcode and some older ones which I previously opened open in QLMarkdown.


The aforementioned warning is shown whenever I try to open a newly dowloaded file with QLMarkdown though, no matter the default.


This does not make any sense at all and it seems I'll just have to avoid Xcode at all costs?


Is there some tool to revert all configuration changes made by XCode and uninstall it along with all the libraries, interpreters and tools it includes?

Apr 5, 2023 11:15 AM in response to etresoft

Thanks for your reply.


Regarding the git tangent:


I encountered this problem myself after installing Xcode as recommended for trying to follow this guide:


Running GUI Linux in a virtual machine on a Mac | Apple Developer Documentation


I later found that UTM better fits my needs.


The problem did not have anything to do with me following SO instructions or something along these lines.


I see Xcode might contain another git executable, but that was completely irrelevant to my problem – it broke my working git installation and git wasn't usable in the default shell or other tools anymore.

Must have been be some kind of misconfiguration on my side then, OTOH: that's why I searched StackOverflow in the first place.


You are probably right about the CLI tools, although that will require me to reinstall.


> > I read something about reinstalling Xcode

> Again, stop reading things on the internet. They are clearly leading you astray. The internet isn't true.


Sorry, but I feel you misread my question, or I wasn't clear enough.


My problems don't have anything to do with me blindly believing StackOverflow answers or believing that "the internet was true".


Does switching to Xcode CLI Tools require reinstalling Xcode?


Thanks!

Apr 5, 2023 11:27 AM in response to etresoft

Thanks, I'll do that (uninstall Xcode) and install Xcode CLI tools when I need them.


Sorry, but I don't see how any of your answers relates to my problem of Xcode overriding the default applications I explicitly set using native OS features. I understand that my post had a frustrated tone and this is a support forum, but if you can't offer a solution, why patronise me?


By the way, how do I leave a block quote at the end of my post here? Neither return nor arrow-down work (Safari on latest macOS Ventura).


Regarding the contents of the quote, I assume that switching from Xcode to Xcode CLI-only tools is the same thing as a reinstall? That's exactly what I read and what I meant, and it is not an actual solution to the problem of Xcode overriding user preferences that it shouldn't care about.


> I read something about reinstalling Xcode
Again, stop reading things on the internet. They are clearly leading you astray. The internet isn't true.

Apr 5, 2023 11:54 AM in response to etresoft


etresoft wrote:

Not really. That's rabbit hole thinking. If you had wanted to install your own copy of git, you could certainly do so and it would work fine. Xcode would not interfere as long as you set it up properly. These things are possible and aren't difficult to do. You just don't need that capability right now.

Sorry, I am not able to produce proper nested quotes using this web UI.


I don't understand what you mean.


  1. I had a working git install before I installed Xcode. I installed git through homebrew, which might be the root cause of the issue.
  2. Then I installed Xcode, and it stopped working.
  3. I managed to fix the problem after a while, but it took me too long for my taste. Why? I did not want to, for example, fiddle with my PATH in .zshrc as suggested in some bad Q&A threads, because I hadn't have to do that before.


You are right that the "guide" I linked to is a low-level example project and probably was the wrong thing for me to follow when I wanted to setup a Linux VM. I managed to follow the guide and adjust the example project, but wasn't happy with the usability of the result and noticed that the Swift code went over my head as I can't program in Swift.


Now we're arguing about petty things. Am I the one who started this?


I don't want to use Linux as my daily driver, I want to have it available for rare occasions when I need it.


It is, essentially, install software correctly and don't take shortcuts. Seems like a simple idea. Haven't found anyone yet who has taken that approach.

Sorry, but how does that relate to Xcode overriding default file extensions set by the recommended way in a native OS UI dialogue, without any notice or indication on how to stop it.


Again, regarding the git tangent: it was apparently caused by my prior git installation coming from Homebrew. When I installed Xcode, there was no indication that it would break existing PATH configuration in such a way, if there was, I did not see it.


The tone of your reply is unpleasant, I admit the tone of my question was too, but I can't take your attitude serious at all.


I'm not a Swift developer, correct.


The headline of the "guide" or more correctly, example project, to me sound as if Apple recommends to use a Linux VM in this way. Where exactly did I "take a shortcut"?

The "shortcut" I needed was UTM.

Apr 5, 2023 12:16 PM in response to moritz116

moritz116 wrote:

1. Sorry, I am not able to produce proper nested quotes using this web UI.

Use the quote tool in the toolbar of the editor widget:


I had a working git install before I installed Xcode. I installed git through homebrew, which might be the root cause of the issue.

Bingo! We have a winner!


I was trying to be sensitive to your concerns. You didn't like that I suggested you stop reading Stack Overflow and other sources of misinformation on the internet. It took every ounce of my energy to avoid mentioning "Homebrew". I sincerely thank you for bringing it up first. These days, pretty much any question along these lines about some strange problem eventually comes back to Homebrew.


If you want to install software on a Mac, you can do so. Install it from the source. Large, popular products like Python have properly signed and notarized installer packages (unlike QLMarkdown). You don't need anything else in those cases. For smaller projects, you might have to install from source. But that is what the Command Line tools were designed for.


Or you can take a shortcut, install Homebrew, and find out that your shortcut only lead you to a misconfigured Mac, asking in a support forum why basic things don't work like they should.

I managed to fix the problem after a while, but it took me too long for my taste. Why? I did not want to, for example, fiddle with my PATH in .zshrc as suggested in some bad Q&A threads, because I hadn't have to do that before.

I agree that you shouldn't copy and paste random things you see on the internet into your dot files. However, learning how PATH works and how to properly manage your dot files is the ideal, long-term solution. Once you get to that point, then you might be able to use something like Homebrew successfully. But without sufficient knowledge, you can easily disable your command line environment altogether. That is very common.

I don't want to use Linux as my daily driver, I want to have it available for rare occasions when I need it.

Maybe you should back up and explain what you are trying to accomplish, at a high level.


That is why I referenced the "rabbit hole". People often start following instructions on the internet, get confused, scramble their systems, and only come here when they get stuck on step # 27. In every case, the answer was not to have started digging in the first place.


If you aren't using Xcode, or Linux, what, exactly, are you trying to do? You've got a whole support forum full of people who will try to help you with that. I tend to hang out in the developer forum or this old "Mac OS X Technologies" forum. But maybe you shouldn't be here at all.

Sorry, but how does that relate to Xcode overriding default file extensions set by the recommended way in a native OS UI dialogue, without any notice or indication on how to stop it.

It's Xcode. It's not a consumer tool. There are different expectations.

When I installed Xcode, there was no indication that it would break existing PATH configuration in such a way, if there was, I did not see it.

Xcode didn't break anything. It was Homebrew that did the breakage.

The tone of your reply is unpleasant, I admit the tone of my question was too, but I can't take your attitude serious at all.

I see no problem with your tone. The fact that you are attacking me for the "tone" of my solutions to your question is amusing, but not surprising.

The headline of the "guide" or more correctly, example project, to me sound as if Apple recommends to use a Linux VM in this way.

That's the developer site. There are different expectations.

Where exactly did I "take a shortcut"?
The "shortcut" I needed was UTM.

Homebrew, internet searches, Stack Overflow. Assuming that Xcode is somehow going to break basic functionality. Wouldn't people have noticed that and fixed it at some point over the past couple of decades?


And I'm totally not convinced you need UTM either. 😄

Apr 5, 2023 12:19 PM in response to etresoft

Correct, sorry, I indeed skimmed your post and didn't even read the part which answers my question.


I shouldn't have conflated the two issues into one to start with.


I am not currently working, this problem occured on my private machine.


Sorry for that again. I still find the UX logic confusing here but that's for another day to get used to.


Regarding the quoting thing:

I meant leave as in "depart" and my question was worded ambiguosly. Found out later that I need to press the return key twice which I am okay with 😀

Apr 6, 2023 4:24 AM in response to moritz116

Just a passing observation. Homebrew on an Intel Mac places binaries (e.g. git) in /usr/local/bin, but on an Apple Silicon Mac, it places the binaries in /opt/homebrew/bin. If you do not place this latter path in your PATH declaration in ~/.zshrc, then you will by default access /usr/bin/git (older version installed by Xcode/CL Tools), and not the homebrew version. On my M1 and M2 Macs, I place /opt/homebrew/bin in my PATH prior to ${PATH) which also inherently includes /usr/local/bin.

Apr 18, 2023 7:47 AM in response to etresoft


Coming back to this some time later after unsubscribing:


My problem was that


  1. I did not know that macOS GUI (or the open command) has a concept of associated applications per-file, not only per-type (or per extension).
  2. What does XCode have to do with it? It associates itself with many file types (json and markdown for example). If there was a prompt about this in the installer and I overlooked it, that's my fault. I'm not sure if there was. I currently do not want to reinstall XCode to check this.


Regarding PATH problems: I know what PATH is, same as I know that macOS isn't Linux.


This discussion steered off-topic, but never did I mention anything about blindly applying StackOverflow answers or something along that line. You mention Internet searches and Homebrew as "shortcuts". I don't understand this snark. Homebrew has concrete advantages which I use it for and I know what it is.


I have been very happy using it, and already fixed the PATH problem before I posted this. I just wondered why this problem occured after installing XCode.


When a software changes my PATH unexpectedly, I don't fix that using duct-tape in my zshrc because I

expect this to cause additional problems or conflicts. That's what I said.


You seem to assume that I blindly apply everything I read somewhere on the internet. This I do not understand, and you wrote quite a bit of text about things that I already know.

For example the differences between Linux and macOS, macOS's BSD/Unix roots etc.


My question minus the snark was a simple question about Finder and file associations on macOS.


You might find me getting angry at XCode amusing, but XCode is required for quite a couple of tasks even for people who do not develop in XCode at all (but who might develop software using other applications and who also use the CLI shell).


Hence your recommendation of the CLI tools version, I guess.


> And I'm totally not convinced you need UTM either. 😄


You don't need to, as you do not know my requirements.


I can explain why I want a Linux VM:


I might need it in the future, e.g. for my job (on another macOS machine), for software that does not run on Mac. And I wanted to explore possible solutions on my private machine beforehand.


I wasn't sure if I need GUI Linux, but I just wanted to try.


I see nothing wrong with that.


Now I hope everyone has a nice day and I learned how to assign file type associations in macOS GUI.

Yay!

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Xcode sets itself als default application to open markdown files even if prompted not to, apparently at login.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.