MacCatalyst and Image of AppIcon

In my apps, I have a requirement to display an image of the application icon is certain circumstances. This is fairly straightforward for iOS/iPadOS and it used to be straightforward for macCatalyst.

For MacCatalyst, this is no longer true (at least since macOS 26). This is because the app icon is now stored as an .icns file and (in the case of using an IconComposer icon), the `'png' in the Asset Catalog now has an unknown name. So the following code no longer works:

public extension Bundle {
    var icon: UIImage? {
#if targetEnvironment(macCatalyst)
        guard let iconName = infoDictionary?["CFBundleIconName"] as? String else { return nil }
        return UIImage(named: iconName, in: self, compatibleWith: nil)
#else
        guard let icons = infoDictionary?["CFBundleIcons"] as? [String : Any] else { return nil }
        guard let primaryIcon = icons["CFBundlePrimaryIcon"] as? [String : Any] else { return nil }
        guard let iconFiles = primaryIcon["CFBundleIconFiles"] as? [String] else { return nil }
        guard let file = iconFiles.last else { return nil }
        return UIImage(named: file, in: self, compatibleWith: nil)
#endif
    }

The obvious solution is to place an Image in the Asset Catalog which I can access, but this is a maintenance headache.

What I would actually like to do is either

  1. create a UIImage directly from the .icns file, or
  2. access the .png file in the Asset Catalog (which has a name beginning with the icon file name, but has additional characters in its name that I don't know).

Can you help?

Answered by DTS Engineer in 900986022

There is no API that returns the app's own icon. UIApplication has setAlternateIconName(_:completionHandler:) and nothing that returns the current one. applicationIconImage belongs to AppKit, which is not available in a Mac Catalyst app.

The supported approach is to include the artwork as an image asset of your own, and display that when you need to show your icon. The .icns and the icon entry in Assets.car are in the bundle for the system to use rather than for the app to read. Neither is something to build on.

Your reading was a reasonable one, since CFBundleIconName is documented as "the name of the asset that represents the app icon" (https://developer.apple.com/documentation/bundleresources/information-property-list/cfbundleiconname). What is not documented is that the asset can be loaded by that name. There is also no hidden name to track down. assetutil reports the asset is named AppIcon, and UIImage(named:) does not return it.

I checked this on a new Mac Catalyst app, macOS 26.5.1 with Xcode 26.6, so it is not specific to your project.

If you would like a supported way to obtain the app's own icon at a given size, that is worth a Feedback Assistant report.

Accepted Answer

There is no API that returns the app's own icon. UIApplication has setAlternateIconName(_:completionHandler:) and nothing that returns the current one. applicationIconImage belongs to AppKit, which is not available in a Mac Catalyst app.

The supported approach is to include the artwork as an image asset of your own, and display that when you need to show your icon. The .icns and the icon entry in Assets.car are in the bundle for the system to use rather than for the app to read. Neither is something to build on.

Your reading was a reasonable one, since CFBundleIconName is documented as "the name of the asset that represents the app icon" (https://developer.apple.com/documentation/bundleresources/information-property-list/cfbundleiconname). What is not documented is that the asset can be loaded by that name. There is also no hidden name to track down. assetutil reports the asset is named AppIcon, and UIImage(named:) does not return it.

I checked this on a new Mac Catalyst app, macOS 26.5.1 with Xcode 26.6, so it is not specific to your project.

If you would like a supported way to obtain the app's own icon at a given size, that is worth a Feedback Assistant report.

FB24261129

MacCatalyst and Image of AppIcon
 
 
Q