How can I set the icon for a Mac Application in Xcode? How can I set the icon for a Mac Application in Xcode? xcode xcode

How can I set the icon for a Mac Application in Xcode?


Since Xcode 4.4 Icon Composer is no longer the recommended way to create icons and is no longer included in the standard install of Xcode.Due to the introduction of Macs with retina display, it is now recommended to provide high resolution versions of all graphics including app icons.

To give your app an icon under Xcode > 4.4 do the following:

  1. Create a folder [IconName].iconset in Finder

  2. In this folder place your icon as png files. You'll need the icon insizes of 16px, 32px, 64px (retina only), 128px, 256px, 512px and1024px (retina only)

  3. These icons must be named with the pattern icon_16x16.png,icon_32x32.png, icon_128x128.png and so on

  4. To support retina displays you must also add icon files with doubleresolution, named icon_16x16@2x.png (with size 32x32),icon_32x32@2x.png (size 64x64) and so on up to icon_512x512@2x.png (size 1024x1024).

  5. drag this [IconName].iconset folder to Xcode (copy if necessary)

  6. in the info.plist file set the "CFBundleIconFile" (Icon File as Key) value to[IconName] but without the .iconset extension

Annotations:

  • it is (currently) not required to provide the @2x icons
  • it will (usually) also work if you don't provide every icon file
  • the iconset folder should not contain a icon_64x64.png file. the 64px icon is only for the retina version of the icon_32x32

Update:In the end your .iconset folder has the following 10 items:

icon_16x16.pngicon_16x16@2x.pngicon_32x32.pngicon_32x32@2x.pngicon_128x128.pngicon_128x128@2x.pngicon_256x256.pngicon_256x256@2x.pngicon_512x512.pngicon_512x512@2x.png

Official guide:

https://developer.apple.com/library/content/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Optimizing/Optimizing.html

Additional information:

To convert the iconset folder to an icns file, run the following command on the terminal:

iconutil -c icns [IconName].iconset

where [IconName] should be replaced with the prefix of the iconset folder. You now have a file called [IconName].icns. In Xcode 4.4, in the Target Summary, right click the question mark for the icon, then select the icns file. You should then see the question mark get replaced with the icon.


As of Xcode 7 (not sure when this was originally introduced), you can use the Assets.xcassets file for app icons. This file is included by default for new projects.

Simply:

  1. Go to your target's settings and ensure that under General, App Icons the Source is set to AppIcon.
  2. Add all 10 png icons to your Assets.xcassets's AppIcon image.
  3. Delete derived data if you have launched the app before, otherwise it will continue to show the default icon.
  4. Run the app; it should now show your icon in the Dock, Application Switcher, and anywhere else it should appear.


Follow these steps to add an application icon to your project. This is the icon that will be show by the MacOS in the doc bar and alt-tab display.

  • Create an icon .icns resource file
  • Place it in the "resources/macos" folder
  • Add it to the resources group in the xcode project
  • Edit the Info.plist file and change the "CFBundleIconFile" value string to "icon"

Also, img2icns tool can come handy to convert images to an icon.