---
name: macos-menubar-tuist-app-dec4e579cbab
description: >-
  Creates and maintains a macOS menu bar app whose Xcode project is generated by Tuist: a SwiftUI MenuBarExtra scene, no Dock icon, manifests in Swift, and a terminal loop that rebuilds and relaunches the app. Covers choosing between a menu and a panel, where fetching and state belong, Quit and Settings items, launch at login, dependencies and tests. Use when the user says "make a menu bar app", "status bar utility for macOS", "set this up with Tuist", "hide the Dock icon", "LSUIElement", "MenuBarExtra", "rebuild and relaunch from the terminal" or "add launch at login".
license: Apache-2.0
compatibility: "macOS with Xcode 16 or later and Tuist 4.62 or later (checked against 4.210). MenuBarExtra needs macOS 13; @Observable and SettingsLink need macOS 14."
metadata:
  author: terminal-skills
  version: "2.0.0"
  category: development
  repository: https://github.com/tuist/tuist
  tags: "macos, menubar, tuist, swiftui, menubarextra"
---

# macOS Menu Bar App with Tuist

## Overview

A menu bar app lives as an icon next to the clock and has no Dock icon and no main window. On macOS 13 and later it takes two ingredients: a SwiftUI `MenuBarExtra` scene, and the Info.plist key `LSUIElement` set to true, which marks the bundle as an agent app. Tuist supplies the project: the targets are declared in `Project.swift`, `tuist generate` writes the `.xcodeproj` and `.xcworkspace`, and the generated files are never edited or committed. This skill covers the decisions, the manifest, the app skeleton, and a build-and-relaunch loop an agent can run without opening Xcode.

## Instructions

### 1. Gather what you need

Ask the user:

- The app name and the bundle identifier prefix (for example `io.harborlane`).
- What the icon and its contents show, and where the data comes from (a local command, a file, an HTTP API).
- The oldest macOS version to support.
- Whether it should start at login, and whether it will be distributed outside the developer's own Mac.

Look up in the folder: an existing `Tuist.swift`, `Project.swift` or `Workspace.swift`; a pinned version in `mise.toml`; `tuist version`; `xcodebuild -version`; any scripts that already build or launch the app. If manifests exist, extend them; do not scaffold a second project beside them.

### 2. Install and pin Tuist

```bash
mise use tuist@4.210.0        # writes the version to mise.toml for everyone on the project
# or, on a single Mac:
brew tap tuist/tuist
brew install --formula tuist

tuist version
```

Producing a project requires a Mac that has Xcode. On Linux the only installer is mise, and anything that calls Xcode (`tuist generate` included) will not run.

### 3. Make the design decisions

| Decision | Options | How to choose |
|----------|---------|---------------|
| Presentation | `.menuBarExtraStyle(.menu)` (the default pull-down menu) or `.window` (a popover-like panel) | A menu when the content is a short list of commands and toggles. A panel when it needs custom layout, scrolling lists, text fields or charts |
| State model | `@Observable` class (macOS 14) or `ObservableObject` (macOS 13) | Follow the deployment target |
| Sources in the manifest | `buildableFolders` or `sources` globs | Buildable folders (Tuist 4.62, Xcode 16) track the file system, so adding a file needs no regeneration. With globs, run `tuist generate` after adding or removing files |
| Below macOS 13 | AppKit `NSStatusItem` | `MenuBarExtra` does not exist there |
| Dependencies | `Tuist/Package.swift` plus `.external(name:)` | Run `tuist install` before generating whenever that file changes |

Keep three layers apart, whatever the app does: a client that talks to the outside world and decodes, a store that owns state, refresh timing and errors, and views that only render the store and send it user intent. A view body that fires a request is refetched on every redraw and cannot be tested.

### 4. Lay out the project

```text
Beacon/
├── Tuist.swift               # tells Tuist where the root is
├── Project.swift             # targets, Info.plist keys, deployment target
├── mise.toml                 # pinned Tuist version
├── Beacon/Sources/           # BeaconApp.swift, BuildClient.swift, BuildStore.swift, BuildListView.swift
├── BeaconTests/              # store and decoding tests
├── Scripts/dev.sh            # rebuild and relaunch
└── .gitignore                # *.xcodeproj  *.xcworkspace  Derived/  .build/
```

### 5. Write the manifests

`Tuist.swift` needs one line of content: `let tuist = Tuist(project: .tuist())`. In `Project.swift`, the menu bar behaviour comes from a single Info.plist entry; everything else is an ordinary macOS app target. Manifests are edited as text, or with `tuist edit`, which opens a temporary Xcode project with autocompletion for them.

### 6. Write the app

- The `App` body holds the `MenuBarExtra` scene and creates the store once. No networking or parsing here.
- The label can change with state: pass a different `systemImage` when something needs attention.
- Always include a Quit control (`NSApplication.shared.terminate(nil)`). Without a Dock icon it is the only way out besides Activity Monitor.
- For preferences, add a `Settings` scene and open it with `SettingsLink` (macOS 14).
- To let users hide the icon, use the `MenuBarExtra` initializer that takes an `isInserted` binding.
- Launch at login is `SMAppService.mainApp.register()` and `unregister()` from the ServiceManagement framework (macOS 13); the user can revoke it in System Settings, so read `SMAppService.mainApp.status` instead of caching a flag.

### 7. Build and relaunch from the terminal

```bash
#!/usr/bin/env bash
# Scripts/dev.sh — regenerate, build, restart Beacon
set -euo pipefail
cd "$(dirname "$0")/.."

APP=Beacon
PRODUCTS="$PWD/.build/DerivedData/Build/Products/Debug"

tuist generate --no-open
tuist xcodebuild build \
  -workspace "$APP.xcworkspace" -scheme "$APP" -configuration Debug \
  -destination 'platform=macOS' -derivedDataPath "$PWD/.build/DerivedData" -quiet

for pid in $(pgrep -x "$APP" || true); do kill "$pid"; done    # stop any copy that is running
"$PRODUCTS/$APP.app/Contents/MacOS/$APP" > .build/$APP.log 2>&1 &
echo "started $APP, pid $!, output in .build/$APP.log"
```

The script starts the executable inside the bundle directly, so the app inherits the shell's environment and its output goes to a log file; `open Beacon.app` would do neither. `tuist generate` opens Xcode unless `--no-open` is passed. `tuist xcodebuild build` is a pass-through to `xcodebuild` (same flags) that also reports timings to a Tuist server if one is configured; `tuist build` is deprecated in its favour. `tuist run Beacon` builds and runs a scheme in one step, but it does not stop a copy that is already running, which is why the script exists.

### 8. Verify before reporting

| Check | Command | Expected |
|-------|---------|----------|
| Manifests compile | `tuist generate --no-open` | Exit status 0, workspace written |
| App builds | `Scripts/dev.sh` | No errors; the script prints the new PID |
| Agent app | `plutil -p .build/DerivedData/Build/Products/Debug/Beacon.app/Contents/Info.plist \| grep LSUIElement` | `"LSUIElement" => 1` (or `true`) |
| Running | `pgrep -x Beacon` | One PID |
| Tests | `tuist test` | All pass |
| Scripts | `bash -n Scripts/dev.sh` | No output |

Then tell the user which commands ran and what they printed, and ask them to confirm the icon is visible: an agent cannot see the menu bar, and on a crowded menu bar macOS may not show every icon.

## Examples

### Example 1: a new menu bar app that shows failing nightly builds

**Request:** "Create a menu bar app called Beacon for macOS 14 that lists our failing nightly builds. Tuist project, no Dock icon."

```swift
// Project.swift
import ProjectDescription

let project = Project(
    name: "Beacon",
    targets: [
        .target(
            name: "Beacon",
            destinations: .macOS,
            product: .app,
            bundleId: "io.harborlane.Beacon",
            deploymentTargets: .macOS("14.0"),
            infoPlist: .extendingDefault(with: [
                "LSUIElement": true,
            ]),
            buildableFolders: ["Beacon/Sources"],
            dependencies: []
        ),
        .target(
            name: "BeaconTests",
            destinations: .macOS,
            product: .unitTests,
            bundleId: "io.harborlane.BeaconTests",
            deploymentTargets: .macOS("14.0"),
            buildableFolders: ["BeaconTests"],
            dependencies: [.target(name: "Beacon")]
        ),
    ]
)
```

```swift
// Beacon/Sources/BuildStore.swift
import Observation

@MainActor @Observable
final class BuildStore {
    private(set) var builds: [Build] = []
    private(set) var lastError: String?
    var failing: [Build] { builds.filter { $0.status == .failed } }

    private let client: BuildClient
    init(client: BuildClient) { self.client = client }

    func refresh() async {
        do {
            builds = try await client.latestBuilds()
            lastError = nil
        } catch {
            lastError = error.localizedDescription   // keep the old list on screen
        }
    }
}
```

```swift
// Beacon/Sources/BeaconApp.swift
import SwiftUI

@main
struct BeaconApp: App {
    @State private var store = BuildStore(client: BuildClient())

    var body: some Scene {
        MenuBarExtra("Beacon", systemImage: store.failing.isEmpty ? "checkmark.circle" : "exclamationmark.triangle.fill") {
            BuildListView(store: store)
                .task { await store.refresh() }
        }
        .menuBarExtraStyle(.window)
    }
}
```

`BuildClient` reads its token with `ProcessInfo.processInfo.environment["BEACON_CI_TOKEN"]` and decodes with optional fields for anything the API may omit. `BuildListView` shows `store.failing`, the error line when `lastError` is set, a Refresh button and a Quit button.

```bash
tuist generate --no-open && Scripts/dev.sh
```

**Result:** `Beacon.xcodeproj` and `Beacon.xcworkspace` appear beside `Project.swift`, the synthesized Info.plist lands under `Derived/`, and the build ends without errors. `pgrep -x Beacon` prints one PID, nothing is added to the Dock, and the checkmark icon switches to the warning triangle when a build fails.

### Example 2: adding Quit and "Launch at login" to an existing app

**Request:** "Beacon has no way to quit, and I want it to start when I log in."

The manifest does not change. A small section goes at the bottom of the panel:

```swift
// Beacon/Sources/PanelControls.swift
import ServiceManagement
import SwiftUI

struct PanelControls: View {
    @State private var startsAtLogin = SMAppService.mainApp.status == .enabled

    var body: some View {
        Toggle("Launch at login", isOn: $startsAtLogin)
            .onChange(of: startsAtLogin) { _, enabled in
                do {
                    if enabled { try SMAppService.mainApp.register() }
                    else { try SMAppService.mainApp.unregister() }
                } catch {
                    startsAtLogin = SMAppService.mainApp.status == .enabled   // show the real state
                }
            }
        Divider()
        Button("Quit Beacon") { NSApplication.shared.terminate(nil) }
            .keyboardShortcut("q")
    }
}
```

**Result:** because the target uses a buildable folder, the new file is picked up without regenerating; `Scripts/dev.sh` rebuilds and restarts the app. Turning the toggle on makes Beacon appear under System Settings, General, Login Items. If the user removes it there, the toggle shows off the next time the panel opens, because it reads `status` instead of a stored preference.

## Guidelines

- Do not edit or commit `*.xcodeproj`, `*.xcworkspace` or `Derived/`. A change made in Xcode's target editor disappears on the next `tuist generate`; put it in `Project.swift`.
- After editing `Project.swift`, `Tuist.swift` or `Tuist/Package.swift`, regenerate before building. A build against a stale project is the usual cause of "file not found in scope" after a manifest change.
- The `.menu` style renders standard menu items only (buttons, toggles, dividers, pickers, submenus). Layout modifiers, text fields and custom drawing are ignored or look wrong there; switch to `.window`.
- Stop the running copy by PID from `pgrep -x` with the exact process name. Pattern matches on a partial name can hit unrelated processes.
- An environment variable exported in the terminal reaches the app only when the executable is started from that shell, as `Scripts/dev.sh` does. A copy opened from Finder or at login does not see it, so for daily use keep secrets in the Keychain. Never hard-code them in a manifest or in Swift sources.
- A locally built app is signed to run on this Mac only. Giving it to other people requires Developer ID signing and notarization, which is a separate job.
- `SMAppService` registers the bundle at its current path. Register from the copy in `/Applications`, not from the build folder, or the login item will point at a path that the next clean build removes.
- `tuist generate`, `tuist xcodebuild` and `tuist test` need Xcode; none of this runs on Linux or in a container without macOS.
- Wrong tool for a conventional windowed app. If the product should sit in the Dock and open documents or windows, remove the `LSUIElement` key and build it around `WindowGroup`.


---
Source attribution: terminal-skills
Original project: https://github.com/TerminalSkills/skills/blob/8a9852d489f274538be9bf1c9121aeb403750b1c/skills/macos-menubar-tuist-app/SKILL.md
License: Apache-2.0
License information: https://www.apache.org/licenses/LICENSE-2.0
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to the Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by the Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding any notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   Copyright 2025 Terminal Skills

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.



# Mega AI Hub resource metadata

Creator / publisher: terminal-skills
Original project: https://github.com/TerminalSkills/skills/blob/8a9852d489f274538be9bf1c9121aeb403750b1c/skills/macos-menubar-tuist-app/SKILL.md
Attribution basis: Source repository record

Fields of work: Development & Engineering, Product Management
Roles: Frontend Developer, Backend Developer, Product Manager
Specialties: Mobile, Backend, Cross Platform
Tools: Tuist, Swift
Country applicability: Country not specified
Classification basis: Source category, role and specialization labels
Instruction SHA-256: 59acb3d4496537a1a207aefb93d8b6bbc843d101a3b1ca3c44d2c183553ec5e9
