ronaldoussoren / py2app

py2app is a Python setuptools command which will allow you to make standalone Mac OS X application bundles and plugins from Python scripts.
Other
349 stars 35 forks source link

app is damaged and can't be opened - does however work in terminal #454

Closed MrBananaPants closed 2 years ago

MrBananaPants commented 2 years ago

So I'm building a simple app to get new listings of an eBay equivalent. The source code is available here.

I'm having a really weird/annoying issue. After building the app with py2app, it works perfectly on my MacBook and I can open/run the app by double-clicking the app icon. However, if I send the app to a friend, the app won't open and gives him the following error message: "CamAlert is damaged and can't be opened". But what's really weird is that he is able to run the app just fine if he launches the app through Package Contents -> Contents -> MacOS -> CamAlert. The terminal window doesn't show any error when launching the app that way on his device (which is the same MacBook as I have).

First I thought it was an issue with the packages not being all included in the setup.py file but the fact that he could run the app just fine through the terminal makes me think the issue is somewhere else.

Feel free to inspect my code or try to build the app yourself.

Edit: the issue seems to be really similar to #450

Edit 2 for some more details: the app only breaks when I send the app to someone or when I download the app from somewhere. The app doesn't break if I just make a zip of it and unzip it. It does however break if I send the app (either the .app file or a .zip of it) to someone or upload it somewhere and download it afterward.

The exact scenario: I sent the app to a friend through iMessage. If I then download the app again from iMessage, it breaks. This happens both when the app is sent as a .app file or a .zip file.

Edit 3: after reading #450 entirely, I acknowledged that I should NOT create files through my python file that are stored inside the app bundle itself. That is however the case right now. I'll try to solve this by storing the files somewhere else or using a package like pickle

KarolWojtyla333 commented 2 years ago

@MrBananaPants When you say

I'll try to solve this by storing the files somewhere else

Do you mean this as in saving the image to a path on any given machine? Or some other method entirely.

MrBananaPants commented 2 years ago

@KarolWojtyla333 There are two .txt files that get created inside the app bundle. You can see it here. Those two files are not present when building the app because they are just two empty txt files which my script makes. Throughout the program, the files get edited a lot and saved again. I think these two .txt files are causing the issues. There's also an app icon (image) and two screenshots in the app bundle but those never get accessed after building the app. They are just static images.

Both .txt files store a string on every line so I can just remove the two .txt files and use two lists instead but I'm not really sure how/where to store a list so it has the same data when the user closes the app and re-open it again.

I could also save the two .txt files somewhere else like at ~/Library/Application Support/MyApp/ but I don't know if that's common practice with Mac apps

MrBananaPants commented 2 years ago

I just made some changes to my app so the two txt files are stored in the user folder which completely fixed the issue! The app now works on other Macs! You can see the changes I've made in this commit. Maybe this is also the fix for #450?

KarolWojtyla333 commented 2 years ago

I just made some changes to my app so the two txt files are stored in the user folder which completely fixed the issue! The app now works on other Macs! You can see the changes I've made in this commit. Maybe this is also the fix for #450?

I tried this and didn't work for me, sadly.