Spencer Williams
Spencer Williams

Reputation: 922

Give an OS X app a custom icon?

Yes, my problem really is that simple. How the heck do I get my app to use the icon file or asset catalog?!

System info:
Xcode 6.1.1 (6A2008a)
app target OS X 10.10
OS X 10.10.1 (14B25)

This is my first OS X app but I have several years' experience developing iOS apps.

Steps to reproduce:

  1. open Xcode, start an entirely new cocoa application project
  2. not sure this matters, but i specified my new project not to use storyboards or core data
  3. drag a .png file from my local directory into the project structure, and make sure (a) it ends up in the build target and (b) the file copies into the project's directory
  4. drag the png into the Images.xcassets catalog under any/all of the sizes classes for AppIcon.
  5. build and run

Expected: app in dock and tab-switcher has the new icon.
Actual: app in dock and tab-switcher has the default "blank page with instruments A on it"

Ok, maybe that's a DEBUG thing.

  1. archive the project, show in finder

Expected: app in Finder has correct icon
Actual: nope. It should be noted however that Xcode's Organizer shows the correct icon, and there does exist a file Contents/Resources/AppIcon.icns. Contents/Info.plist specifies that the Icon File is "AppIcon".

grrr. Let's try without the asset catalog.

  1. in the target's General settings, under App Icon, select "don't use asset catalogs"
  2. delete Images.xcassets
  3. In Info.plist, in the line for Icon File (CFBundleIconFile), specify the icon's name (in my case "AppIcon"). The documentation clearly states that

    The system looks for the icon file in the main resources directory of the bundle.

    File extension is not required here.

  4. build & run. also archive, to save time later.

Expected: app icon in dock and tab-switcher is correct.
Actual: nope
Expected: archived app has correct icon.
Actual: nope, but the archived product did have the correct png file in Contents/Resources.

What am I missing?!

I've tried this with .png app icons and a regular .icns file (generated by Xcode via an asset catalog). I've tried excluding and including the file extension in the Info.plist. Why is this so difficult?

Edit: Clean, Clean Build Folder and deleting the Derived Data folder did not help.

Upvotes: 3

Views: 3328

Answers (1)

Spencer Williams
Spencer Williams

Reputation: 922

So I found the answer through the help of a commenter: I had to fill all of the xcassets/icns slots with images of the exact dimensions.

Upvotes: 3

Related Questions