Ok guys, i have this weird issue that i’ve narrowed down a bit.
If i try to run a .app on my mac right after i’ve built it, it runs fine.
If however i zip it to send it to others to test it, when they unzip the file the resulting .app runs, but the moment it tries to load a file, the app cannot find the file, it gives an access violation. At first i thought it was a permissions thing but it seems its an issue that comes from compressing and decompressing the app.
Anyone has any insight?
No, it’s a permissions thing. The app is sandboxed and can’t find files outside of itself (or the special folders OS X has created for it). If you log the path it’s trying to load, you’ll see it’s some weird path, probably inside /private/var/folders.
I ran into this same issue , and haven’t yet found a good solution. Though I suspect that if we jump through all the hoops of properly code-signing our app, the problem may go away.
Rats…
For saving/loading files I always use Application.persistentDataPath folder. Never had any errors with it on macOS.
As to zipping/unzipping, I know that default macOS archiver (Archive Utility) often breaks correct permissions and attributes on files - especially if archive was created using another program. So an app unpacked from zip archive using Archive Utility may become broken and won’t launch. E.g., a zip archive with executable macOS app created in Windows with WinRAR, and then unpacked on macOS with Archive Utility will be always broken. Using The Unarchiver (I think it was shipped with older versions of macOS, but not included any longer) instead of Archive Utility keeps all permissions intact, and the same app will launch fine. Not sure if it’s related to your problem. But if you used Archive Utility to make zip archives, you can try another utility instead.
I’ve noticed this happening. A local build will work fine but opening a zip from Unity Cloud Build and Application.dataPath will point to the mac’s hidden root folder “/private/var/folders/…” Not expected.
What’s weird though is if I drag and drop the app to another folder, Application.dataPath fixes.