NSFileProviderManager getUserVisibleURL(for itemIdentifier: ) throws error: "The file “...” couldn’t be opened because you don’t have permission to view it."

Hello,

I am encountering an error in my File Provider UI extension where, after calling NSFileProviderManager's getUserVisibleURL(for itemIdentifier: ) method, I receive an error: "The file “...” couldn’t be opened because you don’t have permission to view it."

Looking at the system logs I see the following output:

2024-04-18 12:49:42.847462+0800 0x26c76    Error       0xbec93              6750   0    fileproviderd: (FileProviderDaemon) [com.apple.FileProvider:default] [ERROR] <private> is missing enumerate entitlement to lookup <private>
2024-04-18 12:49:42.847576+0800 0x26c76    Default     0xbec93              6750   0    fileproviderd: (FileProviderDaemon) [com.apple.FileProvider:default] [WARNING] No provider found with identifier <private> for calling bundle (null) on second attempt.
2024-04-18 12:49:42.847688+0800 0x26c76    Error       0xbec93              6750   0    fileproviderd: (FileProviderDaemon) [com.apple.FileProvider:default] [ERROR] Provider ID com.app.name.FileProviderExt is not allowed to provide item ID <private> to consumer ID (null)

This issue only appears on my development machine with the release app bundle codesigned with the intended certificate for release. This is a machine where I have built this same application using a personal development certificate (which works fine and does not face this error). On a second Mac, which has never had this app installed, I do not face this error.

  • For additional context, the application, File Provider extension, and File Provider UI extension are all in the same app group.

    I have also tried building the application for release under different bundle identifiers (e.g. com.app.nametwo.FileProviderExt), to no avail.

Add a Comment

Replies

Try URL.startAccessingSecurityScopedResource()! As described in the 2/2 File Provider video

  • The issue is not with accessing files via the URL received from NSFileProviderManager getUserVisibleURL(for itemIdentifier: ) , the issue is that the call to getUserVisibleURL itself throws the error "The file “...” couldn’t be opened because you don’t have permission to view it." I have no URL to start accessing with a security scope.

  • Ah, my bad 🤦‍♂️ Then, not an expert, but my advice likely a signing/notarization issue: Does your FileProvider have an attached Sandbox capability? What kind of provisioning profile are you using? Developer or Distributed? Are your signing certificates still valid? Is you Main Application within the same App Group as your FileProvider? I personally found this thread to be quite helpful. Hope that helps.

Add a Comment