I compiled and followed the steps with pyInstaller to create the .app file on my Mac, but after following the steps to create the dmg file my app works when I click the dmg file and select the application from where the dmg file was initially created. But if I load my dmg file to google drive, Box drive, or email the dmg file and then try to download and open the dmg file, save the app to the Applications folder, and then run app from the applications folder, I get the error:
“app is damaged and can’t be opened. You should move it to the trash error.”
Not sure what I’m doing wrong since dmg file seems to work fine until I upload it to the internet and then try to re-download it.
The warning you’re receiving may indicate that macOS thinks the application is unsafe & has “quarantined” it. These are automatic checks performed on downloaded files, which is why uploading & downloading is leading to the error – the file probably hasn’t changed, it’s just macOS is now flagging it.
You can check to see if this is the problem by removing the flag from the Terminal.
xattr -d com.apple.quarantine /path/to/app.app
Don’t do this on an .app file you don’t know is safe.
If that solves the problem for your .app bundle, then you’ve found the problem. Obviously you don’t want to be telling users to remove the quarantine flag from your files. To ensure your app doesn’t trigger the warning, you’ll need to sign the app. There are some notes on how to do that here.
Of course, for macOS the most reliable solution would be getting your app listed in the app store.
There are a few possible reasons why your .app file is working fine until you upload it to the internet and then try to re-download it:
File corruption: It is possible that the .dmg file is getting corrupted during the upload or download process. To fix this, you can try using a different file transfer method, such as a secure file transfer protocol (SFTP) client.
Code signing: If you are using PyInstaller to create a .dmg file for a Mac app, you need to code sign the app before uploading it to the internet. Otherwise, macOS will not allow the app to run. To code sign your app, you can use the PyInstaller --codesign option.
Gatekeeper: Gatekeeper is a security feature in macOS that prevents users from installing apps from unknown developers. To allow your app to run on macOS, you need to sign it with a Developer ID certificate. You can get a Developer ID certificate from the Apple Developer website.
Here are some things you can try to fix the problem:
Try using a different file transfer method. If you are uploading or downloading the .dmg file using a web browser, try using a different file transfer method, such as an SFTP client. SFTP clients are more reliable and less likely to corrupt files.
Code sign your app. If you are not code signing your app, try using the PyInstaller --codesign option. To code sign your app, you need to have a Developer ID certificate. You can get a Developer ID certificate from the Apple Developer website.
Disable Gatekeeper. If you are still having problems, you can try disabling Gatekeeper. To disable Gatekeeper, open System Preferences and go to the Security & Privacy pane. Click on the General tab and then click on the Lock icon in the bottom-left corner of the window. Enter your administrator password and then unlock the window. Under the “Allow apps downloaded from” section, select “Anywhere.”
Please note that disabling Gatekeeper can make your Mac more vulnerable to malware. It is recommended that you only disable Gatekeeper if you are sure that the app you are trying to install is safe.