Hide icon from Dock

Hi guy, with this code I can hide my App icon from Dock. But when I try in compiled version don’t work.

I have this code in my App.Open() event:

Dim myProcess As ProcessMBS
myProcess = New ProcessMBS
If myProcess.TransformProcessType(myProcess.kProcessTransformToUIElementApplication) = 0 Then
End If

Why doesn’t it work in the compiled version?

Then I noticed that in debug mode the icon appears for a moment and then disappears. The above code is right at the beginning of the App Open.
Is’t possible not to make it appear at all?

Do you see an error in Console.app?

Also you could just put in key in info.plist to have your app be hidden by default.

Did you try kProcessTransformToBackgroundApplication or kProcessTransformToForegroundApplication instead?

kProcessTransformToBackgroundApplication work in debug mode, work also in compiled mode, but if I move the App in application folder It does not work anymore.

I’d do this

Can you help me? What should I write?

Search for NSUIElement

you need to update your apps plist to have en entry that sets LSUIElement

see https://forum.xojo.com/11024-how-to-start-app-with-no-window-and-without-icon-in-dock
where they discuss how to set this in the plist

<key>LSBackgroundOnly</key> <integer>1</integer>


Note of warning; under 10.14 and newer; there are restrictions applied to applications that hide their dock icon (for security purposes). There isn’t a complete list of the things that Apple deactivate / don’t allow.

I would suggest that you seriously consider two things.

  1. Do you really want to hide the dock icon?
  2. Once your application is complete, are there any features that are impacted by hiding the dock icon.

Good question Sam: why ?

Please try this app out, countdown.zip

If that works correctly, then the NSApp method for hiding the dock icon (the one I’m pretty sure is the preferred method) is functional.

Stunning :frowning: (and unfortunately fake news ;)).

Oh, and disturbing; it makes me seconds to understand what happened.

A very special case. :wink:

lol, I had made it back in February. It had a limited release here on the forum and on twitter. It also apparently will count up when the date passes, heh.

This way for hiding dock icons has been encouraged since around the time code signing apps came into play. Using LSUIElement became impossible for some apps, as you could no longer modify Info.plist due to the signature. Another benefit is that developers have control over the dock icon without needing to relaunch.

I do not downloaded it when you [ANN] it, so without the context, it was disturbing. But, yes, this is an example.

Fake News: who can say for sure this will happens ?
(but a similar scenario appears on TV / Movies and the heroes wins).

Take care all.

just download and try this and icon on the dock bounced and the show ‘2 days to XDC’ which is 2 days ago.