Back to blog
GuidemacOSSwiftUI

How to Build a Menu Bar App for Mac with SwiftUI

A practical introduction to menu bar apps on macOS: when they make sense, how MenuBarExtra works, how to hide the Dock icon, and what makes a menu bar app pleasant to use.

ET

Editorial team

· 2 min read

Key takeaways

  • Menu bar apps suit small, always-available tools: a timer, a clipboard history, a status display.
  • SwiftUI has a built-in MenuBarExtra scene on macOS 13 and later, so a basic menu bar app is a few lines of code.
  • You choose between a menu-style list and a window-style panel, depending on how much interface you need.
  • Launch at login, a keyboard shortcut and quick start-up matter more than extra features.

Some of the most-used apps on a Mac are small ones that sit in the menu bar. They're always one click away, take little space and don't ask for a window. If you have an idea for a small tool, this is a good shape for it.

Is a menu bar app right for you?

It works when the app is:

  • Used briefly and often, like checking the weather, a timer or a clipboard.
  • Glanceable, where the icon or a few characters of text already tell the user something.
  • Background by nature, such as sync, monitoring or a launcher.

If people spend long sessions inside the app, a regular window is a better home.

The basics with MenuBarExtra

From macOS 13, SwiftUI includes a MenuBarExtra scene. You add it to your App and give it a title or icon and some content. There are two styles:

  • Menu style: the content appears as a standard menu. It's quick to build and feels native.
  • Window style: the content appears as a small panel under the icon. Use it when you need controls, a list or a text field.

Start with the menu style. Switch to a window only when a menu can't do the job.

Keep the Dock icon out of the way

A menu bar app usually shouldn't appear in the Dock. Set the Info.plist key that marks it as an agent app (LSUIElement), and it will live only in the menu bar. If you need a settings window, you can open one when the user asks for it.

Details that make it feel right

  • Launch at login. People expect these apps to be there when they sign in. Offer it in settings, using the system's login item API.
  • A shortcut. A global keyboard shortcut makes the app much faster to use.
  • Fast start-up. The icon should appear almost at once. Do heavy work after launch.
  • Light and dark. Use template images for the icon so it adapts to the menu bar.
  • Low resource use. An app that's always running should barely register in Activity Monitor and shouldn't wake the CPU more than it must.

Distribute it

You can ship through the Mac App Store or directly from your website. The store handles updates and payment, while direct distribution gives you more freedom. Our guide on App Store vs direct distribution compares the two, and if you go direct you'll want to notarize the app and set up automatic updates.

Get found

Menu bar apps have a loyal audience, and people look for them in lists. See how others present theirs in our roundup of the best menu bar apps for Mac, then submit yours once it's ready.

Seeing what others fit into a menu bar helps you decide what yours should leave out. A few listed here:

  • DuoBar: battery, Wi-Fi and memory in a single icon.
  • Tuck: hides menu bar icons behind a thin line.
  • Vigil: keeps the Mac awake, with a countdown in the menu bar.
  • Multimeter: small live meters for anything.

Questions, answered.

Something else? Ask us.

What is MenuBarExtra?

A SwiftUI scene, available from macOS 13, that puts an item in the menu bar. Its content can be a menu or a small window.

How do I hide the Dock icon?

Set the Application is agent (UIElement) key to YES in your Info.plist. The app then lives only in the menu bar and has no Dock icon or main menu.

Can a menu bar app be on the Mac App Store?

Yes. Menu bar apps are normal apps and follow the same review rules, including the sandbox if you distribute through the store.

How do I start my app at login?

Use the system's login item API, ServiceManagement's SMAppService, and let the user turn it on or off in your settings.

ET

Written by Editorial team

We install, use and write about indie Mac & iOS apps.

Get your app reviewed

Read more