Created
July 27, 2025 10:03
-
-
Save gornostay25/73603dd1d609686fdde3f32e652a6d11 to your computer and use it in GitHub Desktop.
How to fix “macOS cannot verify that this app is free from malware” issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (* | |
| ## FIX INSTALLER SCRIPT ## | |
| This script allows the user to select an application (.app), | |
| removes the quarantine attribute from it, | |
| and signs it with `codesign` if the tool is available. | |
| @author: gornostay25 | |
| @version: 1.2 | |
| *) | |
| -- Function to check if a command exists | |
| on commandExists(commandName) | |
| try | |
| do shell script "command -v " & commandName | |
| return true | |
| on error | |
| return false | |
| end try | |
| end commandExists | |
| -- Ask user to select an .app bundle | |
| set appAlias to choose file with prompt "Select the .app you want to fix:" of type {"app"} | |
| set appPathRaw to POSIX path of appAlias | |
| -- Remove trailing slash if present | |
| if appPathRaw ends with "/" then | |
| set appPath to text 1 thru -2 of appPathRaw | |
| else | |
| set appPath to appPathRaw | |
| end if | |
| -- Check if the selected path is a valid directory | |
| do shell script "if [ -d " & quoted form of appPath & " ]; then echo 'exists'; else echo 'not found'; fi" | |
| if result is not "exists" then | |
| display dialog "Selected application does not exist." buttons {"OK"} default button "OK" | |
| return | |
| end if | |
| -- Remove quarantine attribute | |
| set removeQuarantineCommand to "xattr -dr com.apple.quarantine " & quoted form of appPath | |
| do shell script removeQuarantineCommand with administrator privileges | |
| -- Sign the application if codesign is available | |
| if commandExists("codesign") then | |
| set codesignCommand to "codesign --force --deep --sign - " & quoted form of appPath | |
| do shell script codesignCommand with administrator privileges | |
| display dialog "The application has been successfully signed." buttons {"OK"} default button "OK" | |
| else | |
| display dialog "codesign command not found. Skipping the signing process." buttons {"OK"} default button "OK" | |
| end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment