How to enable and debug a macOS file provider extension?
Asked Answered
S

1

5

I am trying to build a barebone app with Xcode 12.5 Beta 3 on macOS Big Sur 11.2.2 with a file provider extension. I use the beta version of Xcode because previous versions do not provide a template for file provider extensions (example project on GitHub).

The app and its extension have a common app group set up in their entitlements and are signed automatically with my personal team and a development certificate.

I built and ran my app and extension. But, as far as I know, I have now control over when it is (un)loaded because that is up to the system.

Observations

  1. The file provider extension never shows up in the system preferences.
  2. The Console app does not provide any meaningful information with the distinct project name except "lsd (LaunchServices)" checking whether the application is managed.
  3. The extension does not show up in the Activity Monitor.
  4. Pluginkit reports the extension to be found but prepends an exclamation mark (when running pluginkit -vvvvmi SomeOrganization.SomeProduct.SomeProvider).
$ pluginkit -vvvvmi SomeOrganization.SomeProduct.SomeProvider                                                                                       
!    SomeOrganization.SomeProduct.SomeProvider(1.0)
                Path = /Users/peter/Library/Developer/Xcode/DerivedData/SomeProduct-gyyunhpcbweleidtluxpslpciwjj/Build/Products/Debug/SomeProduct.app/Contents/PlugIns/SomeProvider.appex
                UUID = E2FDC7AB-3CDD-4AEE-A2B2-CC2BA0CBC409
           Timestamp = 2021-03-09 16:49:57 +0000
                 SDK = com.apple.fileprovider-nonui
       Parent Bundle = /Users/peter/Library/Developer/Xcode/DerivedData/SomeProduct-gyyunhpcbweleidtluxpslpciwjj/Build/Products/Debug/SomeProduct.app
        Display Name = SomeProvider
          Short Name = SomeProvider
         Parent Name = SomeProduct

 (1 plug-in)
  1. Filtering the system console by the com.apple.FileProvider subsystem I stumble over these messages after building the extension (I had to reveal private values as described in this answer):
[ERROR] could not load the domain properties
[WARNING] found directory with no domain plist in it: ~/L{5}y/A{17}t/F{10}r/S{26}t.SomeProvider

There are also two others about PhotosFileProvider and com.apple.CloudDocs.MobileDocumentsFileProvider which (I guess) are unrelated. The PhotosFileProvider reports the same warning. The above path can be expanded to:

~/Library/Application Support/FileProvider/SomeOrganization.SomeProduct.SomeProvider

which contains Domains.plist having this (binary) content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>NSFileProviderDomainDefaultIdentifier</key>
    <dict>
        <key>Connected</key>
        <false/>
        <key>Enabled</key>
        <false/>
    </dict>
</dict>
</plist>

Problem

I did not find anything about the meaning of the exclamation mark or how to find out what the actual problem is. How can I debug this? The error in Console sticks out suspiciously. It appears to me like I am missing some piece in the puzzle which is not mentioned in documentation like a secret step in a how-to.

For reference: my question in the Apple Developer Forums.

Sprag answered 9/3, 2021 at 12:15 Comment(3)
I am shipping Strongsync which is a File Provider (and have been working on it since this past July). Happy to help a bit. It's slightly unclear to me why your extension isn't loading. 1. check the log log stream -predicate 'subsystem == "com.apple.FileProvider"' 2. take a peek at "fileproviderctl" which lives on your machine. 3. feel free to grab Strongsync and examine the plist entries made.Lucrecialucretia
Thanks for the hints, @Lucrecialucretia - I updated my observations. I took a look into the Info.plist documents in Strongsync but did not find anything promising so far. fileproviderctl seems to be useful once the extension is actually loaded.Sprag
Can my problem be related to the associated domains entitlement, @hemancuso? Do you have that set up for your product?Sprag
C
5

Are you calling +[NSFileProviderManager addDomain:completionHandler:] from your application? https://developer.apple.com/documentation/fileprovider/nsfileprovidermanager/2890934-adddomain?language=objc

On macOS, unlike iOS, there is not a default FileProvider domain created by the system. Your application must explicitly register domains.

Clinician answered 25/3, 2021 at 0:18 Comment(1)
I did not yet. Thanks! Now I am also abled to debug the running extension. I never encountered this step in my research.Sprag

© 2022 - 2024 — McMap. All rights reserved.