The Application "{application name}" Can't Be Opened on MacOS with .NET MAUI
While figuring out how to publish macOS apps built with .NET MAUI I came across the error in the title. Turns out, there is an easy fix to this and it isn’t .NET MAUIs fault, in fact, this also works for non-.NET MAUI apps. Let’s dive in!
What Causes This Error? #
First, let’s have a better look at the actual error, you can see a screenshot below.
The application “{application name}” can’t be opened. error dialog
From what I can tell, this is caused by macOS making the .app file not executable. This happens when you download a .app file from the internet it seems. The error is similar to something in my earlier blogpost where I wrote about how downloading and compiling code was blocked on macOS.
How To Fix It #
Luckily, the fix is only one command: chmod +x {app name}.app/Contents/MacOS/{app name}
. Make sure to replace {app name}
with your actual app name. You might also need elevated rights for this. In this case append sudo
in front of it.
What this does is; it add the execute (x) flag to your application. If you’re interested in the background, you probably want to learn about chmod
in general.
It Still Doesn’t Work! #
After doing this it still might not seem to work. Apple has implement a couple of things to make your life safer. You might still get a dialog warning you that the application might not be safe and refuses to run. In my case it would say
“{app name}” can’t be opened because Apple cannot check it for malicious software.
This software needs to be updated. Contact the developer for more information.
As you can see the only options are: Show in Finder and OK. None of these options actually opens the app.
In order to get around this, don’t double-click the icon, but instead right-click on the icon and select Open.
Now you will get a slightly different dialog that still warns you, but now also allows you to still open the app. If you’ve done this once, subsequent runs of the app will not show the warning again.