In Unity, how do I solve the error "plugin.bundle is damaged and can’t be opened. You should move it to the Bin"?

Viewed 1755

Using Unity 2019.3.15f1 on MacOS Catalina v10.15.5, I'm using a few plugins in my project to support certain features. The plugins are UniWebView (for showing web views) and NatCorder (to record video & audio during gameplay).

Before the latest MacOS update, everything worked as expected. Without changes to Unity or my project, however, I now get the error '“UniWebView.bundle” is damaged and can’t be opened. You should move it to the Bin' whenever a method of the plugin is called. The editor pauses because of the error, but I can continue playing. While playing continues, none of the features of the plugins work, instead throwing the same error again.

The same occurs for the NatCorder.bundle, and it occurs in other projects using the NatCorder plugin as well. So it doesn't seem to be a problem unique to a specific bundle or project.

This only occurs during testing within the editor. In an Android build, everything works as expected, likely because compilation of the plugin makes it part of the build internally.

To solve it, I've tried to:

  • Reinstall Unity
  • Redownload and install the plugins
  • Complete reimport of all project assets

But nothing works. I'm stumped. Some research suggested it's a problem with MacOS GateKeeper no longer allowing files of unidentified developers to be opened, as the option to 'Allow from anywhere' has been removed from the settings. I don't know when this happened, but I worry it might have been in the latest MacOS update. Manually opening the UniWebView.bundle contents and trying to open a file did throw an unidentified developer warning.

I've tried to use the command 'sudo spctl --master-disable' in terminal to reenable the 'Allow from anywhere' option. That works, the option reappears and seems selected. It does not solve my problem, however, and upon a reboot of the macbook, the setting vanishes once more.

So... I'm out of leads, and nothing's changed. If anyone knows a lead to follow up on, please share. I suspect something changed in the MacOS update that prevents me from using the files in the Unity editor application, but I'm rather new to MacOS and don't know what it could be.

2 Answers

As always after literally a week of searching without results and finally deciding to ask for help, I've found the solution an hour after posting.

Here's the solution:

  1. Open the MacOS terminal.

  2. Enter the command: xattr -d com.apple.quarantine /.../Assets/Plugins/Whatever.bundle

  3. Do this for every .bundle you have, and they once again work.

See more information on the command here: https://www.unix.com/man-page/osx/1/xattr/

I found the solution here at first: https://developer.maxst.com/BoardQuestions/Details/813, but this clears all attributes. It's probably better to only target the attribute that causes the problem, which I found with the base xattr command.

In my case, it was about signing issue. So I update unity version and add code on post build processor like below.

[PostProcessBuild(1000)]
public static void PostProcessBuildAttribute(BuildTarget target, string pathToBuildProject)
{
        if (target == BuildTarget.StandaloneOSX)
        {
            UnityEditor.OSXStandalone.MacOSCodeSigning.CodeSignAppBundle(
                $"{pathToBuildProject}.app/Contents/Plugins/hasProblemFramework.bundle");
            UnityEditor.OSXStandalone.MacOSCodeSigning.CodeSignAppBundle($"{pathToBuildProject}.app");
        }
}

This code works on 2021.2.0b but still not working on 2020.3.13f.

Related