NSFileProviderManager.getDomainsWithCompletionHandler fails with error

I am writing an NSFileProviderExtension for my app. Every once in a while it will get to a point where

    NSFileProviderManager.getDomainsWithCompletionHandler { domains, error in
        DispatchQueue.main.async {
            if let error = error {
               completion(.failure(.domainQueryFailed(error)))
            } else {
                completion(.success(domains))
            }
        }
    }

this always fails, once this happens then regardless of what I do - clean build, restart machine, uninstall plugin nothing works. The only way to get back to a wokring state is a full reinstall of the OS. It seems like when this happens Finder gets to a weird irrecoverable state that only a restart can fix.

Is there anything I can do to address this? I have a laptop which is in this state. Finder has this image attached

First, for a new file provider extension project, you will want to use NSFileProviderReplicatedExtension, and not NSFileProviderExtension, as shown in the following sample project:

Secondly, to look into the issue you described, you can start with gathering more info about the error. Does getDomainsWithCompletionHandler give you any error message? If it doesn't, consider capturing a sysdiagnose by installing the file provider profile and following the instruction.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

NSFileProviderManager.getDomainsWithCompletionHandler fails with error
 
 
Q