I am trying to load an app icon from an icns file. I am using the following code:
guard let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: "com.microsoft.VSCode") else { return nil }
let icon = NSWorkspace.shared.icon(forFile: url.path)
This seems to work very fine for all apps that I tested. All of them? No. Loading the icon for Visual Studio Code takes 4-5 seconds.
Are there any other, faster methods? I also tried to use
NSImage(contentsOfFile: url.path)
which also takes very long. I have uploaded the icns file here (you can of course just use the icns file that comes with your Visual Studio Code installation on macOS, Code.icns).