A have the application with iOS and Mac Catalyst versions and I need to make a cloud client for the app's documents. FileProvider would be the great choice for this feature, but I can't believe it doesn't support Mac Catalyst.
At this moment I'm almost certain that NSFileProviderReplicatedExtension does not support Mac catalyst officially. And if it so, It would be great to hear the exact status and future plans if any.
Unofficially, I managed to run it.
-
I switched the extension's target Supported Destination from Mac Catalyst to Mac and it started to compile. This move seems legit to me.
-
But domain also had to be created, and this part was a way trickier. I've added new bundle to host app(iOS and catalyst), but with supported platform - macOS in build settings. There I created an NSObject subclass DomainManager which calls NSFileProviderManager's addDomain method in its createDomainIfNeeded(), which is also exposed in public extension to NSObject - a kind of "informal protocol"
-
The catalyst app creates bundle by name and loads principal class (DomainManager), but as NSObject reference, and then calls createDomainIfNeeded() method on it.
The location defined by domain appears in Finder sidebar, and the dataless item "a file" appears in this location, as defined by stub implementation in the extension enumerator method. This means file system instantiated the extension instance under Mac catalyst and called the protocol method on it. I.e. it seem to work.
But the question is whether this solution is stable and legit for the App Store distribution. Or is it pandora box with unforeseeable consequences for user data? Thanks in advance.
A have the application with iOS and Mac Catalyst versions and I need to make a cloud client for the app's documents. FileProvider would be the great choice for this feature, but I can't believe it doesn't support Mac Catalyst.
At this moment I'm almost certain that NSFileProviderReplicatedExtension does not support Mac catalyst officially.
Yes, though I think this is really because of a combination of history and general "context":
-
Historically, NSFileProviderReplicatedExtension was supported on macOS before it was supported by iOS. It would have been slightly odd to add a macOS "compatibility" layer for an API that macOS already supported.
-
Catalyst's primary goal/role is to allow you to use UIKit to write macOS apps, but NSFileProviderReplicatedExtension is the kind of extension point that shouldn't be doing ANY interface work (AppKit OR UIKit).
That second point is the critical one here. There are extension points (Notification Service Extension (NSE) is another example*) where exactly the same code would work fine as a both an "iOS project" and a "macOS project" simply because the extension only used APIs that were already available on both platforms.
*Note that the Notification Content Extension (NCE) DOES supports mac catalyst while the NSE does not. The NCE involves interface work (where Catalyst is useful) while the NSE does not.
One other point that isn't always clear in our documentation- the different framework environments we have (macOS, SwiftUI, macCatalyst) are entirely about how the particular target/"object"/component is built, NOT how the different components that make up an app are built. In concrete terms, an app written in macCatalyst should not be calling AppKit APIs. However, there isn't any issue at all with an app written in macCatalyst embedding app extension written in AppKit or SwiftUI.
But the question is whether this solution is stable and legit for the App Store distribution. Or is it pandora box with unforeseeable consequences for user data? Thanks in advance.
It's always tricky to follow exactly what's being done in a text description, however, there isn't any issue with a mac catalyst app including a macOS app extension inside it. This is also the configuration I'd use to support NSFileProviderReplicatedExtension*.
*In theory you might be able to use EXACTLY the same extension on macOS and iOS, but in practice I think you'll end up with different implementations because of differences in usage patterns and user expectations/requirements.
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware