Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 260
Samuel Martineau Avatar asked Sep 17 '20 20:09

Samuel Martineau


People also ask

What is Apple file Provider?

The File Provider framework allows you to integrate your cloud storage into the file system on macOS. It uses new APFS features to allow on-demand downloads of user files and folders. The API is entirely in user space.

What is the Provider file?

↳ androidx.core.content.FileProvider. FileProvider is a special subclass of ContentProvider that facilitates secure sharing of files associated with an app by creating a content:// Uri for a file instead of a file:/// Uri . A content URI allows you to grant read and write access using temporary access permissions.


1 Answers

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.

like image 83
Adam Kopeć Avatar answered Sep 19 '22 04:09

Adam Kopeć