macos-native
Native macOS development with AppKit, Catalyst, and macOS-specific APIs. Use when building Mac-native apps, menu bar apps, system extensions, or macOS-specific features.
What this skill does
# macOS Native Development
Comprehensive guide for building native macOS applications with AppKit and modern macOS APIs.
## Framework Overview
| Framework | Use Case | Notes |
| -------------------- | -------------------- | --------------------------- |
| **AppKit** | Traditional Mac apps | Full control, mature |
| **SwiftUI** | Modern Mac apps | Cross-platform, declarative |
| **Catalyst** | iPad apps on Mac | Quick port, limitations |
| **AppKit + SwiftUI** | Hybrid approach | Best of both worlds |
---
## AppKit Fundamentals
### Application Structure
```swift
// AppDelegate.swift
import Cocoa
@main
class AppDelegate: NSObject, NSApplicationDelegate {
var mainWindow: NSWindow?
func applicationDidFinishLaunching(_ notification: Notification) {
setupMainWindow()
setupMainMenu()
}
func applicationWillTerminate(_ notification: Notification) {
// Cleanup
}
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
}
private func setupMainWindow() {
let contentRect = NSRect(x: 0, y: 0, width: 800, height: 600)
let styleMask: NSWindow.StyleMask = [
.titled, .closable, .miniaturizable, .resizable
]
mainWindow = NSWindow(
contentRect: contentRect,
styleMask: styleMask,
backing: .buffered,
defer: false
)
mainWindow?.title = "My Mac App"
mainWindow?.contentViewController = MainViewController()
mainWindow?.center()
mainWindow?.makeKeyAndOrderFront(nil)
}
}
```
### View Controller
```swift
import Cocoa
class MainViewController: NSViewController {
private let tableView = NSTableView()
private let scrollView = NSScrollView()
private var items: [String] = []
override func loadView() {
view = NSView(frame: NSRect(x: 0, y: 0, width: 800, height: 600))
}
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
loadData()
}
private func setupUI() {
// Setup scroll view
scrollView.translatesAutoresizingMaskIntoConstraints = false
scrollView.hasVerticalScroller = true
scrollView.documentView = tableView
view.addSubview(scrollView)
// Setup table view
let column = NSTableColumn(identifier: NSUserInterfaceItemIdentifier("main"))
column.title = "Items"
column.width = 200
tableView.addTableColumn(column)
tableView.delegate = self
tableView.dataSource = self
// Constraints
NSLayoutConstraint.activate([
scrollView.topAnchor.constraint(equalTo: view.topAnchor, constant: 20),
scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
scrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20),
scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -20),
])
}
private func loadData() {
items = ["Item 1", "Item 2", "Item 3"]
tableView.reloadData()
}
}
extension MainViewController: NSTableViewDataSource, NSTableViewDelegate {
func numberOfRows(in tableView: NSTableView) -> Int {
return items.count
}
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
let identifier = NSUserInterfaceItemIdentifier("cell")
var cell = tableView.makeView(withIdentifier: identifier, owner: nil) as? NSTextField
if cell == nil {
cell = NSTextField(labelWithString: "")
cell?.identifier = identifier
}
cell?.stringValue = items[row]
return cell
}
}
```
---
## Menu Bar Apps
### Status Item
```swift
import Cocoa
class StatusBarController {
private var statusItem: NSStatusItem?
private var popover: NSPopover?
init() {
setupStatusItem()
setupPopover()
}
private func setupStatusItem() {
statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
if let button = statusItem?.button {
button.image = NSImage(systemSymbolName: "star.fill", accessibilityDescription: "App")
button.action = #selector(togglePopover)
button.target = self
}
}
private func setupPopover() {
popover = NSPopover()
popover?.contentViewController = PopoverViewController()
popover?.behavior = .transient
}
@objc private func togglePopover() {
guard let button = statusItem?.button, let popover = popover else { return }
if popover.isShown {
popover.performClose(nil)
} else {
popover.show(relativeTo: button.bounds, of: button, preferredEdge: .minY)
NSApp.activate(ignoringOtherApps: true)
}
}
}
class PopoverViewController: NSViewController {
override func loadView() {
view = NSView(frame: NSRect(x: 0, y: 0, width: 300, height: 200))
}
override func viewDidLoad() {
super.viewDidLoad()
let label = NSTextField(labelWithString: "Menu Bar App Content")
label.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(label)
NSLayoutConstraint.activate([
label.centerXAnchor.constraint(equalTo: view.centerXAnchor),
label.centerYAnchor.constraint(equalTo: view.centerYAnchor),
])
}
}
```
### Menu Construction
```swift
func setupMainMenu() {
let mainMenu = NSMenu()
// App Menu
let appMenu = NSMenu()
let appMenuItem = NSMenuItem()
appMenuItem.submenu = appMenu
appMenu.addItem(withTitle: "About My App", action: #selector(NSApplication.orderFrontStandardAboutPanel(_:)), keyEquivalent: "")
appMenu.addItem(NSMenuItem.separator())
appMenu.addItem(withTitle: "Preferences...", action: #selector(showPreferences), keyEquivalent: ",")
appMenu.addItem(NSMenuItem.separator())
appMenu.addItem(withTitle: "Quit My App", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q")
mainMenu.addItem(appMenuItem)
// File Menu
let fileMenu = NSMenu(title: "File")
let fileMenuItem = NSMenuItem()
fileMenuItem.submenu = fileMenu
fileMenu.addItem(withTitle: "New", action: #selector(newDocument), keyEquivalent: "n")
fileMenu.addItem(withTitle: "Open...", action: #selector(openDocument), keyEquivalent: "o")
fileMenu.addItem(NSMenuItem.separator())
fileMenu.addItem(withTitle: "Save", action: #selector(saveDocument), keyEquivalent: "s")
mainMenu.addItem(fileMenuItem)
// Edit Menu
let editMenu = NSMenu(title: "Edit")
let editMenuItem = NSMenuItem()
editMenuItem.submenu = editMenu
editMenu.addItem(withTitle: "Undo", action: Selector(("undo:")), keyEquivalent: "z")
editMenu.addItem(withTitle: "Redo", action: Selector(("redo:")), keyEquivalent: "Z")
editMenu.addItem(NSMenuItem.separator())
editMenu.addItem(withTitle: "Cut", action: #selector(NSText.cut(_:)), keyEquivalent: "x")
editMenu.addItem(withTitle: "Copy", action: #selector(NSText.copy(_:)), keyEquivalent: "c")
editMenu.addItem(withTitle: "Paste", action: #selector(NSText.paste(_:)), keyEquivalent: "v")
mainMenu.addItem(editMenuItem)
NSApp.mainMenu = mainMenu
}
```
---
## Document-Based Apps
### Document Controller
```swift
import Cocoa
import UniformTypeIdentifiers
class MyDocument: NSDocument {
var content: String = ""
override class var autosavesInPlace: Bool { true }
override func makeWindowControllers() {
let storyboard = NSStoryboard(name: "Main", bundle: nil)
let windowController = storyboard.instantiateController(
withIdentifier: "Document Window Controller"
) aRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.