I will be running user-provided scripts via a Mac application *and* and an extension of the app. The app and extension both belong to the same App Group and individually have the correct entitlements to run scripts.
The Mac app is Sandboxed. According to Apple, any scripts must reside within the Applications Scripts directory: `. applicationScriptsDirectory` / `NSApplicationScriptsDirectory`.
> The NSUserAppleScriptTask class is intended to run AppleScript scripts from your application. It is intended to execute user-supplied scripts and will execute them outside of the application's sandbox, if any.
> If the application is sandboxed, then the script must be in the `NSApplicationScriptsDirectory` folder. A sandboxed application may read from, but not write to, this folder.
The issue I'm facing is that the Main App and the App Extension resolve to different NSApplicationScriptsDirectories:
`let applicationScripts = try! FileManager.default.url(for: .applicationScriptsDirectory, in: .userDomainMask, appropriateFor: nil, create: true)`
- ~/Library/Application Scripts/com.company.MainApp
- ~/Library/Application Scripts/com.company.MainAppFinderSync
I want to run the same scripts from both the App and the Extension. It works to launch scripts from each component's own Application Scripts directory, but the scripts are **not launched** if they reside within the other component's directory.
It is not ideal to maintain a synchronized directory structure, with matching scripts in both locations. It's also difficult to guide the user to put scripts in the correct location, as the main app's Preferences guide cannot open the extension's scripts directory.
**App Groups** solve this issue for other common app/extension scenarios, such as sharing data through NSUserDefaults:
> After you enable app groups, an app extension and its containing app can both use the NSUserDefaults API to share access to user preferences.
Is there any ability to share an Applications Script folder between app and extension that belong to the same App Group?