Configure macOS Menu Bar Icon
Workflow
Inspect the repository and its local instructions.
Locate the real menu bar entry point before editing assets:
- SwiftUI: search for
MenuBarExtra. - AppKit: search for
NSStatusItem,statusItem, orbutton.image.
- SwiftUI: search for
Locate the target's
.xcassetsdirectory and confirm it is compiled by the app target.Do not modify
AppIcon.appiconset, Icon Composer resources,CFBundleIcon, orASSETCATALOG_COMPILER_APPICON_NAMEunless the user explicitly asks for the application icon.Prepare the source:
- Preserve every transparent and partially transparent pixel from the source.
- Never add a white, black, or colored background.
- Never flatten or composite the source before resizing.
- Rasterize SVG sources with the bundled Python renderer (
resvg_py), never Quick Look. - Use solid monochrome artwork for a template image.
- Keep all meaningful artwork inside the canvas.
- If editing SVG strokes, increase the inset by half the stroke-width increase so the outer edge is not clipped.
Generate the menu bar imageset with:
<skill-dir>/scripts/make_menu_bar_imageset.sh <source.svg-or-image> <path/to/Assets.xcassets/MenuBarIcon.imageset>Always use 18 points. The wrapper runs
render_menu_bar_icons.pywithresvg_pyand Pillow. It first uses the systempython3when both dependencies are available. Otherwise, it createsscripts/.venvand installs the pinned dependencies fromscripts/requirements.txt; the first such run requires package-index access. For both SVG and raster input, it createsmenu_18.png,menu_18@2x.png, andmenu_18@3x.pngat 18×18, 36×36, and 54×54 pixels and writes a templateContents.json.Wire the image into the menu bar UI.
SwiftUI
Use the image at its intrinsic 18-point size from the 1x/2x/3x imageset:
MenuBarExtra {
MenuBarContent()
} label: {
Image("MenuBarIcon")
}
.menuBarExtraStyle(.menu)
Use the asset without image modifiers. The imageset already supplies the template-rendering intent and intrinsic 18-point size. Replace an existing systemImage: initializer rather than creating a second menu bar item.
AppKit
Load the asset directly:
statusItem.button?.image = NSImage(named: "MenuBarIcon")
Reuse the existing NSStatusItem. Do not assign image.size or image.isTemplate; the imageset already supplies both properties.
Validation
Confirm the imageset contains:
menu_18.pngat 18×18menu_18@2x.pngat 36×36menu_18@3x.pngat 54×54
Inspect at least the 2x or 3x PNG visually for clipping and legibility.
Confirm the menu bar image has no manual sizing or template-rendering modifiers in SwiftUI or AppKit.
Build the relevant target without signing when practical.
Verify the diff contains no application-icon changes.
Report the source format, intrinsic 18-point logical size, generated 18/36/54 pixel sizes, and build result.
Run the wrapper instead of invoking the Python renderer directly. If dependency installation needs network access in the current environment, request approval and rerun the wrapper. Do not vendor Python packages, invoke uv, or fall back to Quick Look.