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

Answered by DTS Engineer in 854500022

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.

Accepted Answer

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.

Thanks, Ziqiao. I had to reset the box again. I will use the profile the next time it happens.

I am using the NSfileProviderReplicatedExtension in my code. What am I doing wrong in the code segment which made you think that I am using NSFileProviderExtension?

Thanks!

Your previous post started with "I am writing an NSFileProviderExtension for my app." NSFileProviderExtension is the principal class for the non-replicated File Provider extension, and so I thought you were not using NSfileProviderReplicatedExtension.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Ah got it. I am using the NSfileProviderReplicatedExtensionin the app.

NSFileProviderManager.getDomainsWithCompletionHandler fails with error
 
 
Q