3

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.

pkamb
  • 33,281
  • 23
  • 160
  • 191
Spencer Williams
  • 902
  • 8
  • 26
  • You shouldn't need to drag the PNG into the project structure before adding it to the AppIcon in your assets catalog. You should be able to add the PNG to the assets catalog directly from the finder. Are there any warnings indicated for your AppIcon item in the assets catalog? – Aaron Golden Jan 08 '15 at 23:01
  • you're right, I shouldn't need to add the PNG to the project structure. Chalk that up to habit. There are no warnings for the AppIcon as long as the imported png is the correct size. – Spencer Williams Jan 08 '15 at 23:02
  • Oh wait, I had to fill all of the size classes with the correct sizes. Why the eff doesn't Xcode/OS X interpolate?! – Spencer Williams Jan 08 '15 at 23:13
  • OS X does not use PNG files for application icons. It only uses ICNS icons. Xcode will create an ICNS from a .iconset folder or you can do so manually using the `iconutil` command-line tool. There's the old Icon Composer app (doesn't support high-resolution icons) in the Graphics Tools download. Or, you can use a third-party tool. – Ken Thomases Jan 08 '15 at 23:25
  • But I did try an icns file in the project structure, then specifying its name in the plist (I tried to copy an existing app in /Applications). This icns file probably didn't have the right sizes though. womp. – Spencer Williams Jan 08 '15 at 23:28
  • 1
    possible duplicate of [How can I set the icon for a Mac Application in Xcode?](http://stackoverflow.com/questions/6337787/how-can-i-set-the-icon-for-a-mac-application-in-xcode) – Senseful Jul 22 '15 at 21:45
  • Yeah, it looks like that other post does answer a superset of my question, and as long as you follow its directions exactly you'll end up with a good result. – Spencer Williams Jul 23 '15 at 21:21
  • same problem here. I triple checked everything in this and other posts. My app is a screensaver. ( starmessagesoftware.com/moonscreensaver ) Does it make a difference that my bundle is a .saver ? Yes, it does. I just discovered that if I rename the bundle from .saver to .app the icons appears as intended. So many wasted hours. – Mike Apr 09 '16 at 06:57

1 Answers1

3

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.

Spencer Williams
  • 902
  • 8
  • 26