Set File Icon Error

When I set the icon for a file using


[[NSWorkspace sharedWorkspace] setIcon: myImage forFile: [[sheet URL] path] options: NSExcludeQuickDrawElementsIconCreationOption];


2019-11-21 14:34:44.954590-0700 Appname[4856:152311] [default] Invalid image size X: 1024 Y: 1152


XCode 11.2.1 correctly sets the file icon to myImage but logs the error 14 times. This didn't happen in older versions of XCode. The Developer Documentation doesn't say anything about any particular requirements for the size if the NSImage. Setting the the options to either one of the two options doesn't change the error. Is this a spurious error? Am I missing something. Should I file a bug report?

Have you upgraded macOS as well as Xcode? This sounds more like an OS bug than an Xcode bug. But it does look like a bug, since the docs say that the image will be automatically scaled as needed. I'd say do file a bug report, and then try supplying a 1024 x 1024 image.

Yes, latest Versions OSX (10.5.1) and XCode (11.2.1).


I'll file a bug report.

In order to supress this message I created a test image. According to the documentation the image will be scaled to 512 x 512. Even if I create an image that has a size of 512 x 512 the runtime will still report an error when it sets the file's icon. Also true for 1024 x1024. The runtime will correctly set the file's icon to an NSImage, scaling it into the icon. So it looks like this spurious error will be reported for any NSImage regardless of its size.

I wrote too soon. If you use a 256 x 256 image no error will be reported. This doesn't help you create the photorealistic file icons that Apple wants for mac OS.

XCode 11.5 fixed this bug.

After I cleaned and rebuilt my application it did this again so no, Apple didn't fix this.

This is still broken TWO YEARS LATER.

This is still broken FIVE YEARS later.

Set File Icon Error
 
 
Q