Search Issue Tracker

Won't Fix

Votes

0

Found in

2018.4

2019.4

2020.3

2020.3.0f1

2021.1.0a2

2021.2

Issue ID

1323501

Regression

Yes

[macOS] "build is damaged and cannot be opened" error when downloading Unity build from internet

MacOS

-

Reproduction steps:
1. Create a new project
2. Build for Mac
3. Upload build online to Google Drive
4. Download the build (Google Drive will zip it before download)
5. Unzip the build and execute command "sudo chmod -R 755 <path to build>" in terminal (read note 1 for info)
6. Launch the build

Expected result: The build launches successfully
Actual result: ["build" is damaged and can't be opened. You should move it to the Bin.] error window appears

Workaround: execute "xattr -cr <path to build>" and the application will launch

Reproducible with: 2018.4.0f1, 2018.4.33f1, 2019.4.22f1, 2020.3.2f1, 2021.1.0a2, 2021.1.0f1, 2021.2.0a10
Not reproducible with: 2021.1.0a1

Notes:
1. If not executing "sudo chmod -R 755 <path to app>" on the unzipped app you might get an error "opening the app requires administrator permissions" https://apple.stackexchange.com/questions/408752/the-message-you-do-not-have-permission-to-open-the-application-is-shown-when-t
2. The issue is the same as described in 1304455

  1. Resolution Note (2021.2.X):

    The included project modifies files in the application bundle (game.app) in OnPostProcessBuild, after Unity signs it. This invalidates the signature, causing macOS think that the app is damaged.

    When modifying files in the built game bundle in OnPostProcessBuild, you should resign the modifies bundle using this editor API:

    #if UNITY_STANDALONE_OSX
    UnityEditor.OSXStandalone.MacOSCodeSigning.CodeSignAppBundle("/path/to/game.app/Contents/PlugIns/ModifiedBundle.bundle");
    UnityEditor.OSXStandalone.MacOSCodeSigning.CodeSignAppBundle("/path/to/game.app");
    #endif

    You may also resign it using command line codesign tool on macOS:

    codesign -s - -f --deep /path/to/game.app

    There is a closely related issue that causes the command line tool to fail resigning the application bundle after Unity signs it, so the second option will not work until that is fixed: https://issuetracker.unity3d.com/issues/resigning-unity-built-macos-app-results-in-code-signature-data-out-of-place-out-of-place-error

Comments (2)

  1. ribbonrainbow

    Oct 24, 2021 20:01

    I answered with my fix here: https://forum.unity.com/threads/mac-build-breaking-when-uploaded-to-storage.1093330/ and scroll to the bottom

  2. samanabo

    May 25, 2021 21:09

    Is this no longer an issue because the related issue was fixed? Or will mac builds still show this error?

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.