Access sidecar files in a Mac sandboxed app

被刻印的时光 ゝ 提交于 2020-01-10 03:25:17

问题


I need to access sidecar XMP files in a document-based photo editor application. The image files are the documents, and I need to access the sidecar XMP file when the user open and save an image document.

Is it possible to access sidecar files (such as XMP) in a sandboxed document-based application?

I understand that it's not possible by default, but what is the minimal temporary security exception that is needed to allow that?

Is there a workaround for this without using temporary exception?

Note that it's impossible to guarantee the the image files document-scoped bookmarks to the side-cars (as they might created by other apps on different platforms), so this solution won't work.


回答1:


While this question is old I thought I would share my solution. You can add an entry to your CFBundleDocumentTypes section in your apps info.plist with the NSIsRelatedItemType set to true. Then your sandboxed app will be able to open any file the user gives permission to with the same name but has the extensions that you list. Here is an example for an xmp sidecar file:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>xmp</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>XMP sidecar</string>
        <key>CFBundleTypeRole</key>
        <string>None</string>
        <key>NSIsRelatedItemType</key>
        <true/>
    </dict>
</array>


来源:https://stackoverflow.com/questions/14772480/access-sidecar-files-in-a-mac-sandboxed-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!