How to add a File Provider to a MacOS Swift app?
Asked Answered
H

2

7

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.

Homothermal answered 17/9, 2020 at 20:7 Comment(0)
M
6

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.

Mcnalley answered 12/11, 2020 at 16:48 Comment(4)
@Rivera Yes, I can confirm, that this extension launches on both M1 and Intel Macs, although some parts of the protocol are still marked as Beta. However, the core functionality should now work on all Macs running macOS 11.0 or later.Favoritism
The lastest beta of Xcode, 12.5 beta 3 comes with an extension template for file providers (similar to finder sync extensions). This should save you some trial and error. Unfortuantely, I was unable to make it work properly. But this is probably due to my lack of knowledge in Xcode, Swift, etc....Marin
That FruitBasket example by Apple is I think the most complicated example app ever released by Apple.Lafleur
@Lafleur - Totally agree!! :-S And complicated example means unuseful example.Macias
I
2

Grab Xcode 12.5 beta 3 which includes the templates to create a macOS File Provider:

https://developer.apple.com/download/

Instalment answered 16/4, 2021 at 16:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.