Home > database >  FileProviderExtension won't be loaded in macOS 12.2
FileProviderExtension won't be loaded in macOS 12.2

Time:02-10

I am new to macOS development.

I am trying to develop macOS FileProvider extension, and everything was fine until I updated my macOS from 11 to 12.2.

After updating OS, FileProvider extension won't being loaded by NSFileProviderManager.add(domain) and its completion handler returns error - NSFileProviderDomain.Error.providerNotFound

@IBAction func tapAddDomainButton(_ sender: Any) {
NSFileProviderManager.add(domain) { error in
    print("Error: \(error)") // <- Error: Optional(Error Domain=NSFileProviderErrorDomain Code=-2001 "The application cannot be used right now." UserInfo={NSLocalizedDescription=The application cannot be used right now.})
}

}

I've made a new boilerplate project with default macOS > App 'File Provider Extension' in Xcode, and still got same error. Same code works on macOS 11.6.1.

Weird thing is that apple sample code won't return error and still works in macOS 12.2. I can't find any difference between my code and Apple Sample Code.

I uploaded my test project here. Please help

Thanks in advance.

Additional info: My colleague tested in macOS 12.0.1/12.1 and my test project works fine.

CodePudding user response:

I think I managed to this problem.

The key point is AppGroup. FileProvider requires AppGroup capabilities.

I think that a step to reproduce the issue likes below.

  1. Launch provider without AppGroup at first time, and face the FileProvider error.
  2. Add AppGroup capabilities and relaunch.
  3. Still got the error.

New project with adding AppGroup capabilities at first launch won't fail.

CodePudding user response:

I encountered the same problem and even opened feedback with apple. What I figured out (after way too long pulling my hair out) is, as you write, the app group is essential. But not only that, the Extension Info.plist key "NSExtensionFileProviderDocumentGroup" must correspond to your app group.

  • Related