Recent

Author Topic: App Bundle Icon Overridden by Lazarus Assigned Icon  (Read 1160 times)

msintle

  • Sr. Member
  • ****
  • Posts: 281
App Bundle Icon Overridden by Lazarus Assigned Icon
« on: February 04, 2025, 02:33:15 pm »
Does anybody know how Lazarus seems to "burn in" the icon that is specified in the Project Options window for a macOS LCL app?

This icon seems to override the app bundle icon (.app/Contents/Resources/icon.icns), even with everything manifested properly (.app/Contents/info.plist).

Very interesting behavior indeed!

madref

  • Hero Member
  • *****
  • Posts: 1094
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: App Bundle Icon Overridden by Lazarus Assigned Icon
« Reply #1 on: February 04, 2025, 04:52:57 pm »
the icon name must be the same as the app name
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Main Platform:
--------------
Mac OS X Sonoma 14.7
Lazarus 3.99 (Lazarus 3.99 (rev main_3_99-2668-g6b352d830e) FPC 3.3.1 x86_64-darwin-cocoa)

Windows 10 Pro
Lazarus 3.99 (rev cbfd80ce39)

msintle

  • Sr. Member
  • ****
  • Posts: 281
Re: App Bundle Icon Overridden by Lazarus Assigned Icon
« Reply #2 on: February 04, 2025, 06:42:45 pm »
Not even remotely applicable to my question!

msintle

  • Sr. Member
  • ****
  • Posts: 281
Re: App Bundle Icon Overridden by Lazarus Assigned Icon
« Reply #3 on: February 04, 2025, 07:55:46 pm »
Another way to explain what I am trying to get at.

File size of Lazarus binary on macOS compiled WITHOUT icon specified in Project Options:
19,399,272 bytes.

File size of exactly the same source code WITH icon specified in Project Options:
19,473,008 bytes.

So this icon is being stored INSIDE the macOS binary as a resource of some kind (like Windows) or in a separate fork (a la classic macOS?)

And how does Lazarus communicate the presence of this icon to macOS?

It OVERRIDES the icon that is specified as part of the application bundle!

Is there actually a way to have the application bundle icon SUPERSEDE the icon Lazarus is embedding inside the binary?

TRon

  • Hero Member
  • *****
  • Posts: 4003
Re: App Bundle Icon Overridden by Lazarus Assigned Icon
« Reply #4 on: February 04, 2025, 08:05:09 pm »
Is there actually a way to have the application bundle icon SUPERSEDE the icon Lazarus is embedding inside the binary?
Change the icon in your project options.
I do not have to remember anything anymore thanks to total-recall.

msintle

  • Sr. Member
  • ****
  • Posts: 281
Re: App Bundle Icon Overridden by Lazarus Assigned Icon
« Reply #5 on: February 04, 2025, 08:26:01 pm »
Is there actually a way to have the application bundle icon SUPERSEDE the icon Lazarus is embedding inside the binary?
Change the icon in your project options.

Very funny, but no, that is not the answer I am looking for.

Where does Lazarus store the Project Options icon and how can I get rid of it programmatically after a build?

TRon

  • Hero Member
  • *****
  • Posts: 4003
Re: App Bundle Icon Overridden by Lazarus Assigned Icon
« Reply #6 on: February 04, 2025, 08:29:25 pm »
Where does Lazarus store the Project Options icon and how can I get rid of it programmatically after a build?
It is a resource embedded in the executable.

Remove the icon altogether from project options.

You might perhaps think it is funny but who do you think displays that icon ?
« Last Edit: February 04, 2025, 08:32:16 pm by TRon »
I do not have to remember anything anymore thanks to total-recall.

msintle

  • Sr. Member
  • ****
  • Posts: 281
Re: App Bundle Icon Overridden by Lazarus Assigned Icon
« Reply #7 on: February 04, 2025, 08:32:32 pm »
Where does Lazarus store the Project Options icon and how can I get rid of it programmatically after a build?
It is a resource embedded in the executable.

Remove the icon altogether from project options.

That would work, but then there's no way to specify these icons independently for each platform, is there?

That is, keep the icon for Windows, but remove it for macOS? On macOS I can always specify my icon in the app bundle; on Windows, this isn't an option.

Is there a command line compile setting that would make this possible?

Or a way to strip the compiled resource on macOS after a build has been done?

Or even an API call on macOS to "unbind" the resource icon so the app bundle icon takes precedence?
« Last Edit: February 04, 2025, 08:34:26 pm by msintle »

TRon

  • Hero Member
  • *****
  • Posts: 4003
Re: App Bundle Icon Overridden by Lazarus Assigned Icon
« Reply #8 on: February 04, 2025, 08:35:33 pm »
You got a point there msintle.

You could opt for including the resource manually (in code) depending on the platform. I am not aware there is an option present for that in the project options.

edit: I mean that depending on the view of the Lazarus devs /and/ in case there is no other way around it  this might perhaps classify for filing a bug-report/feature-request.
« Last Edit: February 04, 2025, 08:40:10 pm by TRon »
I do not have to remember anything anymore thanks to total-recall.

msintle

  • Sr. Member
  • ****
  • Posts: 281
Re: App Bundle Icon Overridden by Lazarus Assigned Icon
« Reply #9 on: February 04, 2025, 08:41:05 pm »
You got a point there msintle.

You could opt for including the resource manually (in code) depending on the platform. I am not aware there is an option present for that in the project options.

I guess that's a workaround, at least.

Where can I find more information on how Lazarus binds this resource and how it tells macOS to use this resource as the app icon?

Would CocoaInt.CocoaIconUse := false help at all?

Edit: The correct invocation seems to be CocoaConfigGlobal.useIcon and it does not help at all.
« Last Edit: February 04, 2025, 08:54:23 pm by msintle »

TRon

  • Hero Member
  • *****
  • Posts: 4003
Re: App Bundle Icon Overridden by Lazarus Assigned Icon
« Reply #10 on: February 04, 2025, 09:04:43 pm »
Where can I find more information on how Lazarus binds this resource and how it tells macOS to use this resource as the app icon?
I am trying to get my head around this wiki article because if I understood your original issue correctly that seems to contradict your practical experience.

fwiw the article contains some links that might perhaps be of interest to you.

Quote
Would CocoaInt.CocoaIconUse := false help at all?
tbh, I have no idea how resources work with MacOS (other than how resources work with fpc/lazarus).
I do not have to remember anything anymore thanks to total-recall.

msintle

  • Sr. Member
  • ****
  • Posts: 281
Re: App Bundle Icon Overridden by Lazarus Assigned Icon
« Reply #11 on: February 04, 2025, 09:16:46 pm »
Where can I find more information on how Lazarus binds this resource and how it tells macOS to use this resource as the app icon?
I am trying to get my head around this wiki article because if I understood your original issue correctly that seems to contradict your practical experience.

Exactly. The article is all about bundle icons. The crazy discovery for us here is that bundle icons are NOT being honored because of whatever voodoo Lazarus is doing to the compiled binary. Really incredible.

Edit: Pretty sure there's some API the LCL is calling to activate the " resource icon". The app launches correctly with the bundle icon but then this icon is replaced with the "resource icon", never to return.

Shall we be discovering tomorrow that Linux ELF binaries have also supported icons all along in this manner, and Lazarus is of course there to take advantage of it; ignoring whatever has been specified in .desktop files?

fwiw the article contains some links that might perhaps be of interest to you.

Which ones, just to make sure I'm not missing anything?

Quote
Would CocoaInt.CocoaIconUse := false help at all?
tbh, I have no idea how resources work with MacOS (other than how resources work with fpc/lazarus).

Me neither, it wasn't until today that I found out this was even a possibility (a non-app-bundle icon that works on modern macOS [and in fact supersedes the bundle icon outright]).
« Last Edit: February 04, 2025, 09:18:19 pm by msintle »

msintle

  • Sr. Member
  • ****
  • Posts: 281
Re: App Bundle Icon Overridden by Lazarus Assigned Icon
« Reply #12 on: February 05, 2025, 02:03:18 pm »
You got a point there msintle.

You could opt for including the resource manually (in code) depending on the platform. I am not aware there is an option present for that in the project options.

edit: I mean that depending on the view of the Lazarus devs /and/ in case there is no other way around it  this might perhaps classify for filing a bug-report/feature-request.

Unfortunately this workaround doesn't work either :(

The cause?

It's because the code we had painstakingly put together here to determine the size of a binary in Windows:

https://forum.lazarus.freepascal.org/index.php/topic,64996.msg494833.html

Reports the wrong size when I conditionally compile a resource file (something.res) that contains my icon.

Really a bummer, that boxed up feeling, when your workaround seems to require (multiple) additional workarounds.

:'(

TRon

  • Hero Member
  • *****
  • Posts: 4003
Re: App Bundle Icon Overridden by Lazarus Assigned Icon
« Reply #13 on: February 05, 2025, 08:12:24 pm »
I have tried to gather information about how macos is suppose to act in these matter but quite frankly I hit a bit of a wall.

Most likely because my lack of knowledge on/of the platform. Our wiki wasn't particularly helpful either (unless I overlooked/missed it). Took quite some time hence my delayed response.

Would be nice if someone with more expertise/knowledge would be able to chime in also because I lack the hardware to be able to verify/check myself.
I do not have to remember anything anymore thanks to total-recall.

msintle

  • Sr. Member
  • ****
  • Posts: 281
Re: App Bundle Icon Overridden by Lazarus Assigned Icon
« Reply #14 on: February 05, 2025, 09:35:24 pm »
I have tried to gather information about how macos is suppose to act in these matter but quite frankly I hit a bit of a wall.

Most likely because my lack of knowledge on/of the platform. Our wiki wasn't particularly helpful either (unless I overlooked/missed it). Took quite some time hence my delayed response.

Would be nice if someone with more expertise/knowledge would be able to chime in also because I lack the hardware to be able to verify/check myself.

I appreciate the effort very much!

 

TinyPortal © 2005-2018