# Simple cocoa icon question



## iceyg (Feb 29, 2004)

Hey.  This is my first major cocoa programming project in Objective-c and I've had this problem buggin' me all day.

I have an app right now that all it really does is test the classes behind it.  I have a very nice icon for this app also.  I'd like this icon to be the icon for the application in the finder.  I want it to be the icon without resorting to the copy/paste method in the info window in the finder because someone could easy just cut the icon out that way and they're left with the stupid generic application icon.  In Interface Builder I saw the NSApplicationIcon picture in the Images tab, but I found no way to replace it with my icon (and yes my icon is imported in the .icns format).

I looked on the web and the only thing I found that came close to this was this:


```
[NSApp setApplicationIconImage: [NSImage imageNamed: @"Icon_name.icns"]]
```

This changes the appliction icon in the dock though and only during run-time.  

I also saw someone else say that the bundle has to be edited to get my icon in, but that seemed like it came from the pre OS X era and involved resedit.  This is such a simple thing to do that there should be an equally easy answer, if anyone knows can you help?  thank you!


----------



## Gnomo (Feb 29, 2004)

Okay to add the icon to your program is actually fairly easy.

If you have an info.plist file in your project, simply add the following to the dictionary:
<key>CFBundleIconFile</key>
<string>Icon_name.icns</string>

If you don't have an info.plist file, you will need to create one.  I have just typically copied existing plists and changed the entries that I needed to.

After you have added those lines, Next time you compile, your program should have your icon.


----------



## iceyg (Feb 29, 2004)

Sweet, it worked .  It worked after a compile and logout for me though, not just a compile.  Thank you very much...I will have to research this info.plist file to see what other goodies it can provide me, thanks!


----------

