I\'m building a menu bar in my cocoa application with the following code in the @implementation
of my custom application CustomApplication
:
<
I had this issue and the reason was because my call to [NSApp activateIgnoringOtherApps:YES]
was in applicationWillFinishLaunching:
instead of applicationDidFinishLaunching:
.
As soon as I moved it, the menubar worked on first-launch.
Okay, thanks to the remarks of @bhaller I was able to solve my problem.
I actually transferred my calls to the delegate as follows.
-(void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
[CustomApplication sharedApplication];
[CustomApplication setUpMenuBar];
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
}
-(void)applicationDidFinishLaunching:(NSNotification *)notification
{
[CustomApplication sharedApplication];
[NSApp activateIgnoringOtherApps:YES];
}
I fixed by removing LSUIElement
in Info.plist if the app has a Window and Menu Bar.
The old solution is that we override this config with [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
, but in Catalina, it doesn't work anymore.