为 macOS 应用程序提供卸载的最佳方式是什么?

What is the best way to provide uninstall for macOS apps?

我有一个安装在 /Applications/MyApp.app 中的 macOS 应用程序。

应用程序还将一些内容放入 ~/Library/Preferences~/Library/LaunchAgents~/.myappcontent/

如果用户只是从 /Applications 文件夹中删除 MyApp.app,那么所有其他内容仍然存在。甚至 AppCleaner.app 也找不到所有这些东西。

是否有推荐的卸载 macOS 应用程序的方法?比如在某处提供 uninstall.sh 或在 MyApp.app 被删除时执行某些脚本?

到目前为止,我的结论是将应用程序的数据放在 ~/Library/Application Support/<bundle-id> 文件夹中。

AppCleaner.app 或用于 cleaning/uninstalling macOS 软件的其他实用程序会选择那个。

此外,来自 ~/Library/Preferences 的内容也将被拾取(即 plist 形式 StandardUserDefaults