My Mac App Store apps use NSFileProviderReplicatedExtension, and users keep asking how to remove the folder in ~/Library/CloudStorage after deleting the app. Deleting the app leaves the domain registered and the folder in place. fileproviderctl dump shows the domain as "extension not found", and on my own Mac one such domain had survived for five months.
As far as I can tell there is no supported way for the developer to clean this up:
- A sandboxed Mac App Store app cannot run code when it is deleted.
NSFileProviderManager.remove(_:mode:)andremoveAllDomainsonly work while the app is installed.fileproviderctlhas no command to remove a domain.invalidate()is called when the extension is turned off in System Settings, but also on routine teardown, so it cannot drive cleanup.
The one way out I have found is manual. Open the leftover folder in Finder, which says "The application "X" could not be found", and click Delete "X"… in the upper right corner. That removes both the domain and the folder, but users rarely find it on their own.
Is there a mechanism I have missed, such as an Info.plist key or a system behavior, that removes a deleted app's domains automatically? If not, the best I can do seems to be an in-app "Remove from Finder" command that users have to run before deleting the app.
I have filed FB25610224 asking for the system to remove a deleted app's domains, keeping unsynced changes the way .preserveDirtyUserData does.
Thanks for filing the feedback report. I don't think you've missed anything – it's the currently implemented behavior that a file provider domain is left over after the host app is deleted, and that's because there is no good way for the system daemon (fileproviderd) to distinguish an app being removed from the volume that hosts the app being unmounted. Currently, the suggested way to remove a file provider domain after the app is deleted is the user-driven Finder "Delete X..." dialog, as you've mentioned.
Best,
——
Ziqiao Chen
Worldwide Developer Relations.