UnauthorizedAccessException for system folders on Mac OS
hippogamesunity opened this issue · 13 comments
Description of the bug
Hi! I'm testing the plugin on Mac OS and there is an issue with UnauthorizedAccessException when writing to the Root drive.
The situation is:
- the app can list system drives and open files
- the app can't write to Root or Root/Users (UnauthorizedAccessException)
- when I'm trying to move files to Root or Root/Users with Finder, it's asks for a user password (so I think it's considered as secured pathes)
Showing this exception to users blocks me from passing the App Store review, so I'm looking for a workarounds to hide drives or hide inaccessible locations maybe.
Reproduction steps
- save any file to the Root drive on Mac OS
Platform specs
Any Unity, any Mac
Additional info
The app asks for permissions to Documents when starting the first time.
First thing I could think of is, every time the path changes, we check for write access in that directory and if we don't have access, disable the Save button. I'll probably give it a shot sometime soon.
What seems to be the issue in this screenshot?
I mean the error may occur not only for the Root drive, but for others as well.
Btw I've found code to comment to hide drives (as a workaround).
Thanks again for the feedback! I didn't know about sandboxing, will google it while working on a bugfix for this issue.
As you see, these paths are similar to iOS, so I can suggest Mac sandboxing is similar to iOS. BTW you can't send an app to review without adding the Sandbox capability in Xcode. At the same time, even with this feature enabled, you can't test a sandboxed app by running from Xcode. It gets really sandboxed only after downloaded from the App Store. Also I'm noob in Mac OS)
Sorry to bothering you, but I'm trying to provide as much info as I have. Thanks!
Note to self: useful links about app sandboxing:
- https://stackoverflow.com/questions/55218107/nsopenpanel-under-sandbox-access-all-files-inside-user-selected-folder
- https://developer.apple.com/documentation/xcode/configuring-the-macos-app-sandbox#Enable-managed-file-access
- https://stackoverflow.com/questions/13729958/remember-user-selected-folder-and-reopen-it-by-nsopenpanel-under-sandbox
Checking if directory is writeable -natively-:
Writing Mac OS native plugins:
Hi, we're facing this issue in our project and I'm wondering if you're still planning on fixing this issue. Thanks.
My schedule unfortunately won't allow me to fix this issue soon. I'm planning to work on this at some point but not soon.