4

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.

logoutnow
  • 53
  • 1
  • 7

3 Answers3

5

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.

annoyedDev
  • 66
  • 1
  • It seems that the values did not match after changing the AppGroup value several times. When I created a new project and ran it again, it worked well because the values matched. – logoutnow Feb 14 '22 at 02:04
  • I tried running it with the project where the problem occurred, and after changing the NSExtensionFileProviderDocumentGroup value, it ran normally again. – logoutnow Feb 14 '22 at 02:18
1

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.

logoutnow
  • 53
  • 1
  • 7
1

I managed to fix it by changing the app and extension group (com.apple.security.application-groups):

  • From $(APP_TEAM_ID).MyGroup
  • To group.MyGroup
Rivera
  • 10,792
  • 3
  • 58
  • 102
  • However, the Apple documentation says to use `$(APP_TEAM_ID).MyGroup` on macOS. Is it because the documentation is out of date? – logoutnow Feb 14 '22 at 02:01
  • If you are using the archived documentation, it is surprisingly pre-iOS, whereas many other documents in that era are not. – benc Aug 09 '23 at 17:52