Reputation: 262
I'm trying to read a file from Desktop using Finder Sync Extension context menu, but it's not working as expected. I have added all required sandbox settings and other file locations like Downloads are working fine, but Desktop files are not.
Are there any other settings related to Desktop to read/write files?
Upvotes: 1
Views: 467
Reputation: 6166
The issue was resolve by poster, but here's an example: (this is based on an answer from: https://stackoverflow.com/a/58389937/3276518)
Mainly:
Access that can be set directly from Xcode
com.apple.security.files.downloads.read-only
and
com.apple.security.files.user-selected.read-only
Absolute path:
com.apple.security.temporary-exception.files.absolute-path.read-only
Home relative path:
com.apple.security.temporary-exception.files.home-relative-path.read-only
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.downloads.read-only</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.temporary-exception.files.absolute-path.read-only</key>
<array>
<string>/Users/<username>/Music/access.txt</string>
</array>
<key>com.apple.security.temporary-exception.files.home-relative-path.read-only</key>
<array>
<string>/Desktop/access.txt</string>
</array>
</dict>
</plist>
The Documents
folder is not the main folder of the user. In Sandbox context, there's a Documents
folder in the container.
Upvotes: 0
Reputation: 262
The problem was resolved by adding explicitly the absolute path for desktop location in entitlement keys.
Upvotes: 2
Reputation: 35032
Is the Desktop location included in directoryURLs
property of the FinderSync controller?
/*
For each directory present in directoryURLs, the extension can receive -beginObservingDirectoryAtURL: and -endObservingDirectoryAtURL: for that directory and for any directories inside. Always set directoryURLs when the extension starts; if there are no directories to be watched, pass the empty set.
*/
open var directoryURLs: Set<URL>!
You should determine if the issue is due to Sandbox access violation, or an access-level misuse of the FinderSync extension API itself:
let rootDirectory = URL(fileURLWithPath: "/")
FIFinderSyncController.default().directoryURLs = [rootDirectory]
Upvotes: 0