2 Replies
      Latest reply on Sep 13, 2019 12:55 AM by Laszlo
      Laszlo Level 1 Level 1 (0 points)

        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.

         

        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 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    ***    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?

        • Re: Cannot launch new FileProvider extension on macOS 10.15
          Deblanko Level 1 Level 1 (0 points)

          I got it to launch by going to system prefrences -> Extensions and ticking it in there.  Then I got the init etc, but nothing actually happened!

           

          NB. As of Beta 8 (Xcode 11 GM) it has been taken out!!!

           

          PS. If you do add a domain and then change the domain name in your code you may crash the system prefrences -> Extensions tab.  Simply add a removal all domains to your code to tidy up on exit and it will un-crash the prefrences :-)

          • Re: Cannot launch new FileProvider extension on macOS 10.15
            Laszlo Level 1 Level 1 (0 points)

            Update:

             

            In macOS Beta 8 and Xcode 11 GM, NSFileProviderExtension is no longer available to Mac apps. However the documentation says it is available for Mac Catalist apps.

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

             

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