Home > Enterprise >  How to specify different dock icon in Swift for macOS App
How to specify different dock icon in Swift for macOS App

Time:11-27

My app icons are a light blue with clear background and I find that it doesn't show up nicely in the macOS dock. I'm trying to find a way to use a different icon for the dock icon only but can't seem to find a way to do it programatically or through Xcode. The dock icon I created does adhere to the Apple HIG guidelines however I'm not distributing through the App Store anyways. Can anyone help me out? I'm using XCode 13 with Swift 5.

CodePudding user response:

Setting NSApp.applicationIconImage should do what you need.

EDIT: If you need to display a custom icon even when the app is not running, you need to make a dock tile plugin. Unfortunately, documentation on this is pretty scarce, but basically you need to make a plugin target, embed it inside your app's bundle with the extension .docktileplugin, put the path to your plugin in your app's Info.plist under the NSDockTilePlugIn key, and then make the plugin's principal class implement the NSDockTilePlugIn protocol. Also keep in mind that dock tile plugins are not allowed in the Mac App Store, so you'll need to self-publish with a Developer ID certificate if you go this route.

  • Related