1

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?

pkamb
  • 33,281
  • 23
  • 160
  • 191
vikkuu
  • 232
  • 4
  • 11

3 Answers3

2

The problem was resolved by adding explicitly the absolute path for desktop location in entitlement keys.

Rob
  • 26,989
  • 16
  • 82
  • 98
vikkuu
  • 232
  • 4
  • 11
0

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]
pkamb
  • 33,281
  • 23
  • 160
  • 191
  • Yes, I included everything but now the problem has been resolved by adding desktop absolute path in entitlement keys explicitly. – vikkuu Sep 20 '18 at 01:40
0

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.

bauerMusic
  • 5,470
  • 5
  • 38
  • 53