Can't work with SpecialFolder.SharedApplicationData on macOS

I have a customer who has implemented Active Directory on their Macs. Currently, my app saves registration info in the user’s library folder, but apparently Active Directory doesn’t see that. What I need to do is create a Lightwright folder in /Library/Application Support from within my running app. Unfortunately, even when running as Admin, I can’t create a folder there or put info into it - whether in the Finder or in code.

I tried multiple times using the AuthorizationMBS class and the Authorization with Stream example project, which after lots of tries finally worked once and it even let me change the permissions on the newly-created Lightwright folder to 777. However, deleting the Lightwright folder and running the code multiple times afterwards always failed, even after a reboot.

Installers seem to do this easily, but I don’t use an installer because the app needs to write registration info, which can happen at any time after the app is installed.

Thoughts? Suggestions? Help!

SpecialFolder.SharedDocuments should be accessible without elevated permissions for this kind of thing :slight_smile:

So of course, after I explained that Active Directory’s preferred location just simply wasn’t going to work, the reply was, “OK sure! /Users/Shared will be fine.”


1 Like

I recently just went through this too. After trying multiple “potential” solutions, /Users/Shared appeared to be the only “shared” folder between users that I could write too.

I understand that it might be achievable from an XPC process, but my quick tests into trying to make one have all failed.

What does the installer have to do with the app writing registration info?

Another idea is to use an AppleScript app. I need to use a LaunchDaemon as root. The following AppleScript:

set scr to “launchctl load -wF /Library/LaunchDaemons/com.paradigmasoft.vserver_x64.plist”

do shell script scr with prompt “Start Valentina Server” with administrator privileges

is saved as AppleScript app and included in my app. When I launch the app then the user is asked his/her password and the shell script is executed.

1 Like