Irwan
Irwan

Reputation: 793

How to keep list of files or folders on Mac sandboxed app?

I wonder is it possible to keep list of files or folders opened before on sandboxed app without re-opening them or copying to it's own library ?

Thanks in advance

Upvotes: 1

Views: 653

Answers (2)

Leigh  McCulloch
Leigh McCulloch

Reputation: 1976

To keep track of files being accessed by the user, you should create security bookmarks for each file, then that will allow your application to access these files on future runs of the application without getting permission everytime.

I've made this class that wraps up persisting permissions you already have from a using opening a file via NSOpenPanel, and then you can use the class to access that file in the future.

https://github.com/leighmcculloch/AppSandboxFileAccess

Upvotes: 3

dafi
dafi

Reputation: 3522

At this time only using temporary entitlements.

You should use something like

<plist version="1.0">
    <dict>
        <key>com.apple.security.app-sandbox</key>
        <true/>
        <key>com.apple.security.files.user-selected.read-write</key>
        <true/>
        <key>com.apple.security.temporary-exception.files.absolute-path.read-write</key>
        <array>
            <string>absolute path to use</string>
        </array>
    </dict>
</plist>

I hope Apple will clarify how this can be done without 'temporary' solutions because it breaks many many apps

Upvotes: -1

Related Questions