Skip to main content
Hendoi

How to Build a macOS Menu Bar App Using SwiftUI: A Step-by-Step Guide for Beginners

8 min read

macOS menu bar apps are handy for utilities, quick settings, or always-available tools. This guide walks beginners through building one with SwiftUI in Xcode.

Xcode installed on a Mac (latest stable). Basic familiarity with Swift and SwiftUI helps but is not required to follow along. We will create a new Mac app and add a menu bar (status bar) item with a popover.

Open Xcode → File → New → Project. Choose App under macOS. Set product name, team, and organization. Use SwiftUI for interface and Swift for language. Create the project. You get a basic windowed app; we will add a menu bar presence and can suppress or minimize the main window if you want a “menu bar only” feel.

In SwiftUI for Mac you use NSApplication and NSStatusBar from AppKit to add an item to the menu bar. Create a class (e.g. StatusBarController) that: gets NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength), sets a button (image or title), and assigns an action. From that action you can show a SwiftUI popover. Keep a reference to the status item so it stays in the menu bar while the app runs.

Attach an NSPopover to the status bar button. Set its contentViewController to an NSHostingController that hosts your SwiftUI view. Your SwiftUI view can be a simple list of actions, toggles, or a small dashboard. Present the popover when the user clicks the status item; dismiss when they click outside or choose an action. This gives you a “menu bar app” experience with SwiftUI content.

If you want no main window, set your app to not show a window at launch: in the App lifecycle, don’t create a window, or set the window to be closed/hidden. Ensure applicationShouldTerminateAfterLastWindowClosed returns false so the app keeps running when there is no window. The status bar item keeps the app alive and usable.

Build and run (Cmd+R). Test the menu bar item and popover. For distribution you will need to code-sign and notarize the app; Apple’s documentation covers this. For Mac App Store you will need a paid developer account and to follow App Store guidelines.

If you want a menu bar app built and maintained by experts—or need backend integration, sync, or a polished UI—a team like Hendoi Technologies can deliver. We build macOS apps, including menu bar apps, for US, Canadian, and Bengaluru clients. Get a free quote.

📞 +91-9677261485 | 📧 support@hendoi.in | Contact us

Showing slide 1 of 6. Use the buttons below to change slide.

Need web app, mobile app, or desktop app development? We serve USA, Canada, and Bengaluru. React Native, Flutter, MCP servers, AI chatbots, SDKs, APIs. Explore our services and blog for more.

Book a Free Consultation