I need to implement minimal Cocoa application without Xcode. I am trying this example:https://www.cocoawithlove.com/2010/09/minimalist-cocoa-programming.html#import <Cocoa/Cocoa.h>int main(){ [NSAutoreleasePool new]; [NSApplication sharedApplication]; [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; id menubar = [[NSMenu new] autorelease]; id appMenuItem = [[NSMenuItem new] autorelease]; [menubar addItem:appMenuItem]; [NSApp setMainMenu:menubar]; id appMenu = [[NSMenu new] autorelease]; id appName = [[NSProcessInfo processInfo] processName]; id quitTitle = [@"Quit " stringByAppendingString:appName]; id quitMenuItem = [[[NSMenuItem alloc] initWithTitle:quitTitle action:@selector(terminate:) keyEquivalent:@"q"] autorelease]; [appMenu addItem:quitMenuItem]; [appMenuItem setSubmenu:appMenu]; id window = [[[NSWindow alloc] initWithContentRect:NSMakeRect(10, 10, 200, 200) styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:NO] autorelease]; [window setTitle:appName]; [window makeKeyAndOrderFront:nil]; [NSApp activateIgnoringOtherApps:YES]; [NSApp run]; return 0;}It works well, except for one little problem: Immediately after the launch, menu is altered, but is inactive (clicking it does nothing). If I select some other application and then get back to that minimal one, menu starts working as expected.Any idea how to fix this?