Search code examples
swiftmacosfileproviderfileprovider-extension

How to add a File Provider to a MacOS Swift app?


On iOS, there is the File Provider API to create "virtual folders" (folders where the content is provided by an app). How could I do something similar on MacOS? If you wonder why I would want to do this, it's just that I'm trying to understand how cloud storage apps work.

PS: Sorry for bad English, I'm French.


Solution

  • In macOS Big Sur there is a NSFileProviderReplicatedExtension protocol which should "Replicate" the iOS NSFileProviderExtension.
    The API appears to be working on macOS 11.3+ and Xcode 12.5 has brought back the required FileProvider Extension target. There is also a workaround in Xcode 12.2 to add the target manually.
    During WWDC21 we also got some sample code from Apple, which should make the extension a bit easier to implement.