Building and Deploying a Mac Menu Bar Application
By: Sajan Gutta
Tags: Menubar, iOS, Macos, Xcode, Swift

Deploying Your Application

Now that you’ve developed your application, its time to build and distribute a finished version of it. Below are the steps to help you do this.

Making the Application Easy to Uninstall

One unique problem I found with creating a Menu Bar application came when trying to uninstall it. After creating a build and running it, the application properly appears and stays in the menu bar. However, uninstalling it yields an error since the application is still open. Usually, you could click the app’s icon in the dock at the bottom of your screen to quit the application but we prevented that icon from showing up earlier when we edited Info.plist.

A simple fix for this is to provide the user with an option in the UI to quit the application. Then, if the user does want to uninstall your application, they can click the quit button and then uninstall like normal. This is much simpler than having to dig through their Activity Monitor to kill the relevant processes to quit the application. Below is a simple bit of SwiftUI code that you can use for your button.

Button(action: {

exit(-1)

}) {

Text(“Quit App”)

}

Creating an Archive/Build of the Application

Note that if you want to share your application with others, you have to join the Apple Developer Program. To deploy your application, you first want to make sure you have the proper settings in the project settings. Navigate to the project’s general settings. Be sure to choose an app category, Bundle Identifier, Version Number, Build number, Deployment Target, Main Interface, and your App Icon (note: this is different from the icon you made earlier for the menu bar). You can see what this looks like below.

Configure these settings in your project’s settings

Now, to create a distributable version of your app, select Product > Archive within Xcode. The following window will pop up.

The Xcode archives window.

From this window you will select your new archive, and click Distribute App. In the next window, select “Developer ID.” Click next and then select “upload” to get your application notarized by Apple. This will take a few minutes and then you will be able to choose a location to save the distributable version of your app. You will now find a build of your app in the selected location. Move this into your Mac’s Applications folder and run it. Your app should now be working!

Releasing Your App Outside of The App Store

Apple has numerous release options for your application which you can check here. However, you may want to distribute your application outside of the App Store. I’ve found that the best way to do this is to perform a GitHub release. The application build you made in the last section can be uploaded to GitHub as a release of your repository. From there, others will be able to download and install your application in seconds!

Congratulations!

You’ve just created your first macOS Menu Bar Application! I hope this tutorial was helpful for navigating the process. Feel free to ask questions and/or leave a comment. I’ve also provided a list of the resources referenced in this article below for you to use.

Resources

1. Mac API Tool: Use this resource to either download the application I created or to check the code in AppDelegate.swift to learn how to create the menu bar item for your application.

2. Aaron Wright’s Article: This is a great article with code related to AppDelegate.swift. It helped me when creating my own application and is definitely worth a read.

3. Apple’s Distribution Options: Check out this article to learn about the different ways to distribute your application.