“appname.app is damaged and can’t be opened. You should move it to the Bin” error on macOS Catalina

Since macOS Catalina I came across the error “appname.app is damaged and can’t be opened. You should move it to the Bin” while running Xamarin.Forms reproductions for macOS apps. This is due to the more protective measures that are implemented. In this post I will tell you a little bit about it and more importantly; how to fix it.

The Error

Long even before Catalina macOS has been marking files that are downloaded from the internet with a filesystem attribute. It seems that from 10.5 (Leopard) a File Quarantine was introducted. However, from Catalina and up, it seems the protection has been upgraded and you won’t be able to simply run anything you’ve downloaded.

On the one hand, very safe, on the other hand, kind of annoying at times. What is sort of impressive if you put it in the “running reproductions” perspective, is that macOS appereantly also is able to detect that a binary is built from code and also marks that with the com.apple.quarantine attribute. That is the attribute that is causing this issue.

You can see the resulting dialog below.

Catalina error dialog appname.app is damaged and can’t be opened. You should move it to the Bin
Catalina error dialog appname.app is damaged and can’t be opened. You should move it to the Bin

Note that this error can be caused by other reasons as well. And keep in mind; this dialog is not just there to be annoying. It is actually there to warn you about potentially suspecious things going on. So be sure that you know what the code/app is doing before you proceed here.

Because the rootcause can be different, this fix might not work in every scenario.

How to fix “appname.app is damaged and can’t be opened.”

Luckily, the fix is quite easy. It took me a while to find it though. That’s why I decided to give it a little visibility in a blog post. Of course the truth is that I just keep forgetting how to do it and I just need this as an easy reference 😉

Open a Terminal window and simply run this command: xattr -d -r com.apple.quarantine <foldername>. This should delete (-d) the com.apple.quarantine attribute recursively (-r) from every file in the folder you supply. Note that the foldername doesn’t have to have angle brackets, you can just replace it with the foldername or path.

I have found a couple of scenarios where this wasn’t enough. There is also the -c parameter switch which clears all attributes of the files. To use this, simply replace -d with -c like so: xattr -c -r com.apple.quarantine <foldername>.

The output for that command in the Terminal will be nothing, unless you did something wrong. But it will just pause a little while and return input to you. If you are in fact using this with source code, you might want to delete the bin/obj folders to be sure and do a full rebuild.