Apple documentation specifies that NSWorkspace icon(forFile:) returns a 32x32 icon, but I'm not sure how to specify a different size.
This is a sample SwiftUI code I'm using to display the icon for XCode:
Image(
nsImage: NSWorkspace.shared.icon(forFile: "/Applications/XCode.app/")
).renderingMode(.original)
One way I found is to use
bestRepresentation. You should pass in the dimensions you want the image to be in (e.g. 1024x1024), and it will find you the best representation there is for that size.Then you can just
drawtheNSImageRep, or create anNSImageusing it: