/olko-apple-kit:macos-menubar-appfrom olko-apple-kit
Build a production-quality macOS menubar or notch app in SwiftUI, covering MenuBarExtra setup, sandbox entitlements, keyboard shortcuts, sound effects, accessibility permissions, and /critique-driven polish cycles. Use when starting or extending a macOS agent app that lives in the status bar or Mac notch area.
Ships in olko-apple-kit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
🤖 Auto-generated by weekly-pattern-learner · SwiftUI macOS menubar app pattern observed in FocusNotch session, Jun 2026 (364 user turns, ~48 MB transcript covering idea → spec → impl → critique cycles → App Store)
Build a macOS app that lives in the menu bar or notch using SwiftUI's MenuBarExtra. Covers the full lifecycle: project setup, window management, entitlements, user interaction (keyboard shortcuts, sound), and App Store preparation.
Create a new macOS App target in Xcode:
com.yourname.AppNameMenuBarExtra)In Info.plist, set:
<key>LSUIElement</key>
<true/>
This hides the app from the Dock: the menu bar becomes the only entry point.
@main
struct FocusApp: App {
var body: some Scene {
MenuBarExtra {
ContentView()
.frame(width: 320, height: 480)
} label: {
Label("Focus", systemImage: "timer")
}
.menuBarExtraStyle(.window)
}
}
Use .menuBarExtraStyle(.window) for a popover-style panel. Use .menuBarExtraStyle(.menu) for a dropdown menu.
On MacBooks with a notch, the safe area changes. Detect and adapt:
func isNotchPresent() -> Bool {
guard let screen = NSScreen.main else { return false }
// The notch area is excluded from visibleFrame top
let screenHeight = screen.frame.height
let visibleTop = screen.visibleFrame.maxY
return visibleTop < screenHeight
}
Position windows below the notch:
window.setFrameOrigin(NSPoint(
x: window.frame.origin.x,
y: NSScreen.main!.frame.height - window.frame.height - notchOffset
))
Minimum .entitlements for a sandboxed menubar app:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<!-- Add only what the app actually uses: -->
<!-- <key>com.apple.security.network.client</key> -->
<!-- <true/> -->
</dict>
</plist>
For focus/blocking features that need accessibility:
<key>com.apple.security.temporary-exception.apple-events</key>
<array>
<string>com.apple.systemevents</string>
</array>
To detect which app is in focus (required for distraction blocking):
import ApplicationServices
func requestAccessibilityPermission() -> Bool {
let options: NSDictionary = [kAXTrustedCheckOptionPrompt.takeUnretainedValue() as String: true]
return AXIsProcessTrustedWithOptions(options)
}
Call this on first launch and prompt the user to grant access in System Settings → Privacy → Accessibility.
import AVFoundation
class SoundPlayer {
private var player: AVAudioPlayer?
func play(_ filename: String, extension ext: String = "mp3") {
guard let url = Bundle.main.url(forResource: filename, withExtension: ext) else { return }
player = try? AVAudioPlayer(contentsOf: url)
player?.play()
}
}
Add sound files to the Xcode target (check Target Membership in file inspector).
For system sounds (no file needed):
NSSound.beep()
// or
NSSound(named: .init("Hero"))?.play()
Global shortcuts (work when app is not focused); requires Accessibility permission:
NSEvent.addGlobalMonitorForEvents(matching: .keyDown) { event in
if event.modifierFlags.contains([.command, .shift]) && event.keyCode == 36 { // ⌘⇧↩
// Handle shortcut
}
}
Local shortcuts (SwiftUI):
.keyboardShortcut("s", modifiers: [.command, .shift])
@AppStorage("timerDuration") private var timerDuration: Double = 25 * 60
@AppStorage("soundEnabled") private var soundEnabled: Bool = true
For complex state, use UserDefaults with a suite name to share across extensions.
After each implementation slice:
Optional skills: Steps 1 and 3 require
/critiqueand/whimsy-injectorfrom the agent-skills catalog. Install them viaskillshareif not already available; skip these steps if not installed.
/critique: evaluate against Apple HIG, WCAG contrast, interaction consistency/whimsy-injector on completion screens and idle statesSee olko:apple-store-submit for the full submission and rejection-handling workflow.
Pre-submission checklist:
# Validate archive
xcodebuild archive -scheme <AppName> -archivePath build/<AppName>.xcarchive
# Check sandbox
codesign --verify --deep --strict build/<AppName>.xcarchive/Products/Applications/<AppName>.app
# Verify entitlements
codesign -d --entitlements :- build/<AppName>.xcarchive/Products/Applications/<AppName>.app
| Symptom | Cause | Fix |
|---|---|---|
| App appears in Dock | LSUIElement missing | Add to Info.plist |
| Menubar icon missing after build | Asset catalog misconfigured | Use PDF or SVG template image, tick Template Image |
| Crash on click | View not loaded in popover window | Add .frame() to MenuBarExtra content |
| Sound not playing | File not in target | Check Target Membership in file inspector |
| Accessibility prompt not shown | Missing entitlement | Add temporary-exception.apple-events or use XPC |
| Notch overlap | Hardcoded y-position | Detect visibleFrame vs frame delta |
LSUIElement = true)codesign --verify --deep --strictWhat SKILL.md sets; muted values are Claude Code's defaults
3 skills in this plugin
/apple-store-submitHandle Apple App Store rejection emails end-to-end: parse rejection reasons, create a fix plan, implement code changes (privacy strings, entitlements, sandbox), navigate App Store Connect to update metadata, and resubmit. Use when an app receives a rejection or when preparing a first-time submission./app-store-regional-pricingResearch and configure App Store and in-app purchase prices by storefront using affordability evidence and available Apple price points.Other plugins' skills for the same job
npx claudepluginhub oleg-koval/agent-skills --plugin olko-apple-kit