How to install Mac app icon in Xcode?

I know a lot about writing Objective-C code and developing in Interface Builder, and I wanted to set icons for my simple programs.

I added the same JPG to all the size fields in Icon Composer and got ICNS, but I could not figure out how to add it to the project.

Thanks in advance.

+74
xcode cocoa icons macos
Jun 14 2018-11-11T00:
source share
7 answers

Since Xcode 4.4 Icon Composer is no longer the recommended way to create icons and is no longer part of the standard Xcode installation. Thanks to the introduction of a Mac with a retina display, it is now recommended to provide high-resolution versions for all graphic objects, including application icons.

To provide your application with an icon under Xcode> 4.4, follow these steps:

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

  2. In this folder, place your icon as png files. You will need a 16px, 32px, 64px icon (retina only), 128px, 256px, 512px and 1024px (retina only)

  3. These icons should be named with the template icon_16x16.png, icon_32x32.png, icon_128x128.png, etc.

  4. To support retina displays, you must also add dual-resolution icon files, such as: icon_16x16@2x.png (with size 32x32), icon_32x32@2x.png (size 64x64), etc. Up to the version: 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 value "CFBundleIconFile" (file icon as a key) to [IconName], but without the extension .iconset

Annotations:

  • (currently) no @ 2x icons required
  • it (usually) also works if you do not provide each icon file
  • The iconset folder should not contain the icon_64x64.png file. 64px icon is for retina version only icon_32x32

Update. At the end, your .iconset folder contains the following 10 items:

icon_16x16.png icon_16x16@2x.png icon_32x32.png icon_32x32@2x.png icon_128x128.png icon_128x128@2x.png icon_256x256.png icon_256x256@2x.png icon_512x512.png icon_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 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 named [IconName] .icns. In Xcode 4.4, in the Goal Summary, right-click the question mark for the icon, then select the icns file. Then you should see that the question mark is replaced by the icon.

+148
Aug 28 2018-12-12T00:
source share

Follow these steps to add an application icon to your project. This is the icon that MacOS will display in the doc panel and on the alt-tab screen.

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

In addition, the img2icns tool can come in handy for converting images to an icon.

+26
Jun 14 2018-11-11T00:
source share

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

Simply:

  • Go to your target settings and make sure that in General , application icons for Source is set to AppIcon.
  • Add all 10 png icons to the AppIcon Assets.xcassets image.
  • Delete derived data if you started the application earlier, otherwise it will continue to show the default icon.
  • Launch the application; now it should show your icon in the Dock, Application Switcher and in any other place where it should appear.
+20
Jul 22. '15 at 21:40
source share

Steps to add an application icon to a cocoa project.

  • Find "Icon Composer" from the spotlight.
  • Drag the icon (the name should be like imagename.icns) in the specified fields.
  • Select one field and save it.
  • Drag the saved image into the "Resources" folder of your application.
  • Select a target → right click on the project name → Choose GetInfo.
  • In the properties, enter the name "Icon File".
  • Now clean the assembly and run the application.
+7
Jul 21 '11 at 10:20
source share

Easily

  • Use an automatic tool (such as IconFly) to create the correct ICNS or set of icons with all the required sizes.

  • Then drag and drop an ICNS or icon set in Xcode.

  • in the info.plist file set the value "CFBundleIconFile" to [IconName]

+7
Apr 15 '13 at 23:22
source share

Xcode 8.2.1

  1. Convert.png 👉.icns via IconMaker

  2. Add the AwesomeApp.icns file to the same folder as info.plist

  3. Drag and drop the AwesomeApp.icns file in xcode to the same folder as info.plist

  4. In the set.plist icon: before AwesomeApp.icns

+2
Mar 02 '17 at 14:12
source share

Step 1: Get the icon file name from info.plist and put the icns folder (icon file) in the SourceCode / resources folder

Step 2: The same thing happens for xcode, you need to copy all the images from xcode using copyallframeworks or copyall resource file to your xcode and create the application again.

0
Jul 14 '17 at 12:28
source share



All Articles