Cannot launch new FileProvider extension on macOS 10.15

I am trying to get the File Provider extension to work on macOS 10.15 Beta 7 (19A546d) with Xcode 11 Beta (11M392r) so far did not manage to get it to launch with a sample project. The documentation is very lacking and there must be something I missed.


I have a Mac app that does the following on launch:


let domain = NSFileProviderDomain(identifier: NSFileProviderDomainIdentifier(rawValue: "com.app.testfileprovider"), displayName: "TestFileProvider", pathRelativeToDocumentStorage: "")

NSFileProviderManager.add(domain) { error in
    if let error = error {
        NSLog("Could not add file provider for domain: \(error)")
        return
    }

    guard let newManager = NSFileProviderManager(for: domain) else {
        NSLog("Could not create file provider manager.")
        return
    }

    self.manager = newManager
    NSLog("File provider URL: \(newManager.documentStorageURL.path)")
}


I sometimes get this error, not sure why:

Could not add file provider for domain: Error Domain=NSFileProviderInternalErrorDomain Code=3 "The value “com.myappbundleid” is not valid for the parameter “callerBundleID”." UserInfo={NSLocalizedDescription=The value “com.myappbundleid” is not valid for the parameter “callerBundleID”.}


The error may be resolved by a "killall Finder" command in Terminal, then it runs successfully, and outputs:

File provider URL: /Users/[username]/Library/Group Containers/group.com.myappgroup/File Provider Storage


In Finder the “File Provider Storage” folder appears with a cloud badge, which seems to be OK. I guess.


I have my File provider extension class, which is basically the generated code when I added the File provider extension to my Mac app in Xcode:


class FileProviderExtension: NSFileProviderExtension {
    var fileManager = FileManager()
    override init() {
        NSLog("File provider initialized")
        super.init()
    }
    ...


Here the “File provider initialized” message is never logged and the extension is never initialized. I cannot get it to launch at all.


In the Console.app this is the only relevant message I could find:


default 09:14:35.447849+0200 *** com.apple.launchservices - 45683955: Checking whether application is managed at file:///Users/laszlo.agardi/Library/Developer/Xcode/DerivedData/FileProviderMacTest-eebpahoydvfxovantvhkplhgrcty/Build/Products/Debug/FileProviderMacTest.app/Contents/PlugIns/FileProviderExt.appex//com.myapp.fptest.FileProviderExt


What I did so far:

  • the app and extension are sandboxed, it is set in the entitlements files
  • the app and extension share the same app group, also set in entitlements
  • Tried to launch the extension:
    • Run the file provider from Xcode, Xcode was waiting for the extension to launch
    • I opened the File Provider Storage folder in Finder, it has the cloud badge. But no file action inside or just browsing launches the File provider extension


What am I missing? How do I get the File Provider extension to launch on macOS Catalina?

After checking it out in macOS 11 Beta 4 and Xcode 12 Beta 4:
  • There is no option to add a File Provider extension target to a macOS app

  • The documentation has a macOS support section but lacks actual documentation on how it should be used

  • The documentation says the NSFileProviderExtension class is only available on iOS

Do you have any working sample code? Can someone confirm if this new macOS 11 API is something we can use to build file provider extensions?

I also updated my feedback with the latest info: FB7262787

Can someone confirm if this new macOS 11 API is something we can use to build file provider extensions?

When you build a demo macOS app with NSFileProviderExtension, you'll get the error: 'NSFileProviderExtension' is unavailable in macOS.

Confirmed in macOS 11 Beta 4(Xcode 12 Beta 4)

I presumably though that macOS NSFileProviderExtension isn't ready yet.
As I recently rechecked the FileProvider - macOS Support page, surprisingly, the page got updated.
https://developer.apple.com/documentation/fileprovider/macos_support-ari
Https://archive.is/BPFDB

But there seems have no sample code for macOS, also I don't know how to load the file provider extension in my test app... anyone got any idea?

It seems that NSFileProviderReplicatedExtension still in beta state.

macOS 11.0 beta 10, Xcode 12.2 beta3
The code written in Swift
BTW, Objective-C still cannot compile the NSFileProviderReplicatedExtension, it complains

'NSFileProviderExtension' is unavailable: not available on macOS

Very likely being a bug of Xcode beta.
Hi, All, does there any sample code for macOS FileProvider API?
I cannot find any sample code in https://developer.apple.com/documentation/fileprovider/macos_support.

I don't know how to load a FileProvider API currently, is there anyone can help with this?
I managed to get the File Provider extension working with some tricks with Xcode 12.2 RC (Version 12.2 beta 4 (12B5044c)) and macOS 11.0.1 RC (Version 11.0.1 Beta (20B5022a))

You cannot add a File Provider Extension target in Xcode (FB8889071). However it can be worked around by adding a different extension target then modifying the info.plist file accordingly. E.g. I added a Finder Sync Extension then modified the NSExtension part of the info.plist similar to an iOS File Provider Extension:

Code Block
<key>NSExtension</key>
<dict>
<key>NSExtensionFileProviderDocumentGroup</key>
<string>group.com.yourappgroup</string>
<key>NSExtensionFileProviderSupportsEnumeration</key>
<true/>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.fileprovider-nonui</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).FileProvider</string>
</dict>


I’m not sure if all these keys are needed, but I guess the NSExtensionPointIdentifier and NSExtensionPrincipalClass must be set. The NSExtensionPrincipalClass value must be set to the class that implements the NSFileProviderReplicatedExtension protocol in your extension target.

Then in my app I do the following after launch to set up a file provider:

Code Block
let domain = NSFileProviderDomain(identifier: NSFileProviderDomainIdentifier("com.myapp.fileprovider"), displayName: "MyAppFileProvider")
NSFileProviderManager.add(domain) { error in
print("Add file provider domain: \(error as NSError?)")
let manager = NSFileProviderManager(for: domain)
manager?.signalEnumerator(for: .rootContainer, completionHandler: { error in
print("Signal change error: \(error as NSError?)")
})
}


This will add the file provider to the sidebar in Finder.
I got this so far, can enumerate items similar to iOS file provider.

The way the File Provider Extension should be set up, and how we should work with it is still lacking documentation and an example project.

In my investigations:

OneDrive can run in Big Sur without FileProvider, in OneDrive, each placeholder file have a xattr named com.apple.fileutil.PlaceholderData, and bound with a launch service xattr com.apple.LaunchServices.OpenWith.
Evidence:
Code Block
$ xattr -l 'Getting started with OneDrive.pdf'
com.apple.LaunchServices.OpenWith:
00000000 62 70 6C 69 73 74 30 30 D2 01 02 03 04 57 76 65 |bplist00.....Wve|
00000010 72 73 69 6F 6E 5F 10 10 62 75 6E 64 6C 65 69 64 |rsion_..bundleid|
00000020 65 6E 74 69 66 69 65 72 10 00 5F 10 24 63 6F 6D |entifier.._.$com|
00000030 2E 6D 69 63 72 6F 73 6F 66 74 2E 4F 6E 65 44 72 |.microsoft.OneDr|
00000040 69 76 65 2E 44 6F 77 6E 6C 6F 61 64 41 6E 64 47 |ive.DownloadAndG|
00000050 6F 08 0D 15 28 2A 00 00 00 00 00 00 01 01 00 00 |o...(*..........|
00000060 00 00 00 00 00 05 00 00 00 00 00 00 00 00 00 00 |................|
00000070 00 00 00 00 00 51                |.....Q|
00000076
com.apple.fileutil.PlaceholderData:
00000000 44 45 4E 4F 01 00 00 00 03 00 00 00 50 01 00 00 |DENO........P...|
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000020 02 00 00 00 30 01 00 00 00 00 00 00 00 00 00 00 |....0...........|
00000030 03 13 06 00 00 00 00 00 33 32 37 33 41 46 43 44 |........3273AFCD|
00000040 35 36 41 41 36 45 35 37 21 31 30 32 00 00 00 00 |56AA6E57!102....|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000060 33 32 37 33 41 46 43 44 35 36 41 41 36 45 35 37 |3273AFCD56AA6E57|
00000070 21 31 30 32 00 00 00 00 00 00 00 00 00 00 00 00 |!102............|
00000080 00 00 00 00 00 00 00 00 33 32 37 33 41 46 43 44 |........3273AFCD|
00000090 35 36 41 41 36 45 35 37 21 31 30 31 00 00 00 00 |56AA6E57!101....|
000000A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000000B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000000C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000000D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000000E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000000F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000120 00 00 00 00 00 00 00 00 33 32 37 33 61 66 63 64 |........3273afcd|
00000130 35 36 61 61 36 65 35 37 00 00 65 00 74 00 74 00 |56aa6e57..e.t.t.|
00000140 69 00 6E 00 67 00 20 00 73 00 74 00 61 00 72 00 |i.n.g. .s.t.a.r.|
00000150


OneDrive seems utilized the com.apple.fileutil kernel extension via kernel control sockets.
Code Block
$ kextstat | grep fileutil
161 0 0xffffff7f81773000 0x18000 0x18000 com.apple.fileutil (20.036.15) E3E63A3C-BE10-3DB3-A89F-F2313C192EB0 <6 5 3 2 1>
$ netstat -n
...
Registered kernel control modules
id flags pcbcount rcvbuf sndbuf name
d 0 1 8192 8192 com.apple.fileutil.kext.stateful.ctl
e 0 3 8192 2048 com.apple.fileutil.kext.stateless.ctl
...


Yet the document is only available to Apple and OneDrive.
And as far as I know, the com.apple.fileutil kext come as early as in macOS 10.14



The similar pattern also apply to Dropbox as I rechecked Dropbox in Big Sur recently:

Code Block
$ pwd
~/Dropbox
$ xattr -l 'Get Started with Dropbox.pdf'
com.apple.metadata:_kMDItemUserTags: <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><array><string>Online-only</string></array></plist>
com.dropbox.attrs:
00000000 0A 12 0A 10 9F B5 39 2F 57 E3 32 10 00 00 00 00 |......9/W.2.....|
00000010 00 00 00 05 10 E4 FF B9 82 03 |..........|
0000001a
com.dropbox.placeholder:
00000000 03 00 00 00 AC 18 A3 2B 00 00 00 00 0A 12 0A 10 |.......+........|
00000010 9F B5 39 2F 57 E3 32 10 00 00 00 00 00 00 00 05 |..9/W.2.........|
00000020 10 E4 FF B9 82 03 |......|
00000026
$ netstat -n
Registered kernel control modules
id flags pcbcount rcvbuf sndbuf name
...
b 4 0 32768 2048 com.apple.fsplaceholder.logging
c 4 1 32768 16384 com.apple.fsplaceholder.kauth
...
$ pwd
/Applications/Dropbox.app/Contents
$ strings Frameworks/python-extensions/macinfinite_native.cpython-37m-darwin.so | grep fsp
infinite_dbkext_load_fsplaceholder_kext
infinite_dbkext_unload_fsplaceholder_kext
k_infinite_kauth_fsplaceholder_kern_control_name
com.apple.fsplaceholder.kauth
load_fsplaceholder
release_fsplaceholder
$ pwd
/System/Library/Extensions/FSPlaceholder.kext/Contents/MacOS
$ strings FSPlaceholder | grep -i dropbox
com.dropbox.placeholder
.dropbox.cache
Dropbox
$ nm FSPlaceholder | grep sysctl
         U _sysctlvfs_children
0000000000005108 D _sysctlvfs_fsplaceholder
0000000000005260 S _sysctlvfs_fsplaceholder_children
0000000000005210 D _sysctlvfs_fsplaceholder_connected_clients
00000000000051a8 D _sysctlvfs_fsplaceholder_connected_logging_clients
0000000000005158 D _sysctl__vfs_fsplaceholder_kext_version
# Before we launch Dropbox.app
$ sysctl vfs.fsplaceholder
vfs.fsplaceholder.kext_version: 1.13.2
vfs.fsplaceholder.connected_logging_clients: 0
vfs.fsplaceholder.connected_clients: 0
# After we launched Dropbox.app
$ sysctl vfs.fsplaceholder
vfs.fsplaceholder.kext_version: 1.13.2
vfs.fsplaceholder.connected_logging_clients: 0
vfs.fsplaceholder.connected_clients: 1
# vfs.fsplaceholder.connected_clients down to zero after we closed Dropbox.app


Like before, no document at all, exclusive support for Dropbox.



So both Microsoft and Dropbox have corporation with Apple before the macOS FileProvider API is ready.
Which is unfair to many of us who used deprecated KPIs, we now cannot use FileProvider, and EndpointSecurity can't suit in our use cases.
And our customers complain about why your app is malfunctioned.

We have urged(via feedback) to speed up development of macOS FileProvider API, which Apple, disappointed us for a long time.
Hi Guys,

I've tried to add File Provider Extension target for macOS but not successful. This option is still not visible on Xcode 12.3 (12C33) and macOS 11.2 Beta (20D5029f).

I really hope we can start using this API to build on-demand feature for our product, it'll be really usful. Does anyone know when this API will be available for public access?

Thanks.
Chih


Hi, @Laszlo.

Can you describe the detail of how you register and load the File Provider Extension?

I managed to change the Info.plist, yet I failed to launch the File Provider Extension.
Hi @nslx,

You have to add a file provider domain from your app using the NSFileProviderManager class. See the example in my previous comment, I believe it has all the details: https://developer.apple.com/forums/thread/122351?answerId=645095022#645095022

Also be sure to keep the Console.app open as it can be very informative with errors.
Hi again, @Laszlo.
Can you upload your current working sample code to GitHub for example?
After signaled enumerate root container, I failed to establish the connection with my File Provider Extension.
I cannot figure out the reason behind it, maybe your sample code is helpful to me. :-P
@nslx did you solve it? I think we have the same problem as @nslx that we fail to establish the connection.
Can anyone provide a working sample?
@wollnyst, not yet solve it.

I thought Apple just still working on it, and we're operating on a black box.
I hope if Apple finally got this released, a sample code would be a great relief to us.
Cannot launch new FileProvider extension on macOS 10.15
 
 
Q