Cannot launch new FileProvider extension on macOS 10.15

1.4k Views Asked by At

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.


Update

In macOS Beta 8 (19A558d) and Xcode 11 GM (11A419c), NSFileProviderExtension is no longer available to Mac apps. However the documentation says it is available for Mac Catalyst apps.

When I try to build a Mac Catalyst app with file provider extension I get the following errors:

error: 'TestFPExtension.appex' is a File Provider extension, which is not available when building for Mac Catalyst. You may need to restrict the platforms for which this app extension should be embedded in the target editor. (in target 'TestFP2' from project 'TestFP2')

error: File Provider extensions are not available when building for Mac Catalyst. (in target 'TestFPExtension' from project 'TestFP2')

The app builds without errors for iOS. It seems this File Provider API is not yet available on Mac at all.


Original Question

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 target 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 lsd 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?

0

There are 0 best solutions below