Bug 10346 - Icon not working for Xamarin.Mac Application
Summary: Icon not working for Xamarin.Mac Application
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: 1.0.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Jeffrey Stedfast
Depends on:
Reported: 2013-02-16 17:51 UTC by Mortaza Doulaty
Modified: 2013-03-05 02:08 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Icon file which I created according to Apple's documentation (3.38 MB, application/octet-stream)
2013-02-16 17:51 UTC, Mortaza Doulaty

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Mortaza Doulaty 2013-02-16 17:51:02 UTC
Created attachment 3391 [details]
Icon file which I created according to Apple's documentation

For my Xamarin.Mac application, in project setting page, I added the icon in 'Mac OS X Application' as written in http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AppleHIGuidelines/IconsImages/IconsImages.html

But it does not seem to be showing that icon. I've attached the icon file.

I've also posted this on Xamarin.com forum and there jstedfast suggested to post the bug here.
Comment 1 Aaron Bockover [MSFT] 2013-02-25 15:25:46 UTC
Assuming you have a valid .icns file (if you're not sure, grab one from another .app to try), the correct procedure in Xamarin Studio for setting an application icon is:

- Add a .icns icon to the project's [blue] Resources folder
- Ensure the added .icns file's Build Action is 'BundleResource' (this should
be set for you simply by adding a file to the Resources folder)
- Go to Project Options > Build > Mac OS X Application
- Click the 'App Icon' button
- Select the .icns file under Project Folders > Resources
- Press OK
- Press OK on Project Options
- Build/Run
- Observe application icon is set in OS X dock
Comment 2 Jeffrey Stedfast 2013-02-27 22:02:09 UTC
FWIW, I've just fixed the App Icon button in the Info.plist editor to allow picking any *.icns file anywhere on the file system. If the file isn't already part of your project, it adds it to the project, too.

Mortaza: where does the icon not show? in the Info.plist editor/Project Options, or in the app itself when you run it?

I noticed while I was implementing the above feature that we were storing the icon name with the ".icns" file extension and it seems like Xcode doesn't do that, so I've updated the code to not save the ".icns" extension into the Info.plist file.

I've also fixed some logic for finding the icon file based on the plist name used in the info.plist, so this might have been the problem.

I'll try to look into this more tomorrow.
Comment 3 Jeffrey Stedfast 2013-02-28 14:10:22 UTC
Mortaza: I created a new Xamarin.Mac project in Xamarin Studio and then opened the Info.plist, clicked the icon button in the "Mac OS X Application" section and selected the icon that you attached and it loaded fine.

I also tried it in the Project Options under "Mac OS X Application" and that worked as well.
Comment 4 Mortaza Doulaty 2013-02-28 16:25:16 UTC
The issue is like this: when I select in icon in 'Options > Build > Mac OS X Application' which is not in resources folder (but copied as content file), then despite the fact that it loads and displays the icon in 'Mac OS X Application' section, but when application runs, it will not show it in dock. But when the file is put in resources folder, it works.
Comment 5 Jeffrey Stedfast 2013-02-28 17:33:39 UTC
Okay, so... the problem is that Apple expects the icon to be in MyApp.app/Content/Resources/ and not in a subdirectory of that.

That means that your icon file needs to live in the Resources folder in Xamarin Studio or else at the toplevel of the project (not in a subfolder).
Comment 6 Mortaza Doulaty 2013-02-28 17:35:17 UTC
Yes, that it. I think it needs to be reflected properly so that users (like me!) know how to set the icon properly.
Comment 7 Jeffrey Stedfast 2013-02-28 18:24:16 UTC
Okay, I've just updated the code to warn the user that the icon needs to be in a toplevel Resources folder (or the toplevel project dir) when the user selects an icon.

If the user selects an icon that is already in the project, it offers to move it to the right place for them.
Comment 8 Mortaza Doulaty 2013-02-28 18:25:01 UTC
That would be great! Thanks.
Comment 9 Jeffrey Stedfast 2013-02-28 18:30:03 UTC
no problem :-)
Comment 10 Atin 2013-03-05 02:08:10 UTC
Today we have checked this issue with following builds:

X.S 4.0 - 2be9833ca58a68b3d64be96a40ab7e149647fed1
Xamarin.mac- 1.2.32
Mono- 2.10.11 (mono-2-10/2baeee2)

After setting .icns to App icon when we debug/run Xamarin.mac application, It displayed updated icon in Dock.

Changing the status to Verified.