Fetching Tinted Folder Icons in macOS Tahoe using Swift

In macOS Tahoe, users can tint folders or add symbols. But when trying to access that customized icon in Swift, the system always returns the default folder icon.

NSWorkspace.shared.icon(forFile: url.path)
try url.resourceValues(forKeys: [.effectiveIconKey]).effectiveIcon
try url.resourceValues(forKeys: [.customIconKey]).customIconKey

All of these give back the standard folder icon without any of the user-applied customization.

So the question is: Is there any API or workaround in Swift to retrieve the actual customized folder icon (including tint and symbol) as displayed in Finder on macOS Tahoe?

Yes. See the post here: https://developer.apple.com/forums/thread/805177

The only problem is that it's async. So what I have to do is use the old-style initially and then update that asynchronously.

And the problem being discussed in the above thread is valid. If the user changes the icon while your app is running, you can't get the new version.

Fetching Tinted Folder Icons in macOS Tahoe using Swift
 
 
Q