Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

programming-osx

/programming-osx

Podpowiada praktyki aplikacji na macOS: zarządzanie oknami i poleceniami, AppKit i SwiftUI, dostęp do plików w piaskownicy oraz dystrybucję.

Repozytorium
octomind-tap ↗
Licencja
Apache-2.0
Ostatnia zmiana repozytorium
12.11.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
6
Przestarzałość

Brak sygnałów. Repozytorium zmienione 12.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

Co robi i kiedy

Podpowiada praktyki aplikacji na macOS: zarządzanie oknami i poleceniami, AppKit i SwiftUI, dostęp do plików w piaskownicy oraz dystrybucję.

Oryginalny opis (EN)

macOS app practices: window and command ownership, AppKit and SwiftUI, sandboxed file access, distribution. Use when building or reviewing Mac apps.

Jak działa

  1. Overview
  2. Mental model
  3. Platform gate
  4. Windows, commands, and UI
  5. Files and sandbox boundaries
  6. Helpers, lifecycle, and distribution
  7. Example
  8. Checklist
  9. References
Sekcje z nagłówków SKILL.md, w oryginale · 80 linii, 879 słów
Podgląd SKILL.md
---
name: programming-osx
title: "macOS App Development Best Practices"
description: "macOS app practices: window and command ownership, AppKit and SwiftUI, sandboxed file access, distribution. Use when building or reviewing Mac apps."
license: Apache-2.0
compatibility: "Requires Xcode and the project's supported macOS SDK/deployment target; signing tools for distribution."
capabilities: programming-swift
domains: developer
rules:
  - content(macos)
  - content(osx)
  - content(appkit)
  - content(cocoa)
  - match(mac.+app|macos.+app|osx.+app|desktop.+app)
---

## Overview

Use for native macOS app implementation and review. Focus on windows, commands, files, sandbox boundaries, and distribution; preserve the application's SwiftUI/AppKit architecture and deployment contract.

## Mental model

A Mac app may have many independently focused windows and continue running with none visible. Model document, scene, and process lifetimes separately. File access and helper execution depend on explicit user/system authority, not just a path or process-wide singleton.

## Platform gate

As of 2026-10: Xcode 27 (Swift 6.4 compiler, macOS 27 SDK, runs on macOS Tahoe 26.6+) is the stable release; Xcode 27.1 is at release candidate and 27.2 in beta. Bundled helpers built with non-Apple toolchains carry their own minimum macOS (for example, Go 1.27 binaries require macOS 13+); check it against the app's deployment target. Apple's compatibility table distinguishes compiler, build SDK, host OS, and deployment target. Check these independently before adopting APIs; use actual symbol availability, not the installed machine's OS, as the minimum-version contract.

MenuBarExtra, NavigationSplitView, and SMAppService are available from macOS 13; Observation and SwiftData from macOS 14. Keep a supported AppKit implementation when it fits. Avoid speculative compatibility layers or raising deployment targets just to use a newer spelling.

## Windows, commands, and UI

- Use WindowGroup for independently instantiable windows, Window for a unique utility window, and DocumentGroup when document ownership fits. Keep window-specific selection, navigation, and drafts out of a process-global model.
- Route commands to the focused scene/selection using focused values or the established responder chain. Disable unavailable actions and provide keyboard shortcuts; don't locate a target with `NSApplication.shared.windows.first`.
- Store scene restoration values separately from documents. `@SceneStorage` is for lightweight restoration, not durable user content. Validate restored identifiers against current files and permissions.
- Use native Table, sidebar, toolbar, Settings, and menu patterns where suitable. Preserve keyboard focus, selection, undo/redo, VoiceOver labels, and resizing; don't port touch-only interaction unchanged.
- Use system controls/materials for macOS 26 styling, applying Liquid Glass to navigation/control surfaces deliberately. Test contrast and reduced transparency instead of layering decorative effects over content.
- Bridge AppKit with representables or hosting views/controllers at a clear boundary. Update existing native objects rather than recreating them on every render; remove observers and break callback ownership cycles during teardown.
- A menu-bar app needs explicit open/settings/quit behavior. `LSUIElement` controls Dock presence; it does not define the entire window-activation policy. Use MenuBarExtra or NSStatusItem according to actual behavior required.

## Files and sandbox boundaries

- Separate App Sandbox from Hardened Runtime: sandbox entitlements constrain resource access; hardened runtime and signing govern execution protections. Direct distribution does not require the same sandbox policy as the Mac App Store.
- Let users select external files through supported panels/document APIs. Persist security-scoped bookmarks when access must survive relaunch; resolve stale bookmarks and refresh them through the documented flow.
- For a security-scoped URL, balance each successful `startAccessingSecurityScopedResource()` with `stopAccessingSecurityScopedResource()`. Keep access active for the whole operation; denial is an error, not a reason to retry through an unrestricted path.
- Use coordinated/document-aware access for externally managed documents. Preserve file contents and surface save conflicts; don't replace an unreadable document with an empty one or delete data to recover from migration failure.
- Store credentials in Keychain. Grant only entitlements needed by the feature; a broadly permissive entitlement is not a fix for an unexplained access failure.

## Helpers, lifecycle, and distribution

- Keep UI state on its intended actor and long-running work outside the UI execution path. Closing a window and quitting the process are distinct events; explicitly own tasks, observers, and subprocesses.
- Use SMAppService for supported login-item/helper registration. Handle enabled, disabled, and approval-required states explicitly; don't repeatedly register to defeat a user's choice. Give XPC services and extensions narrow interfaces and validate requests.
- Don't add privileged helpers or system extensions unless the requested feature requires their privileges. Entitlement eligibility and approval flow must be verified for the actual extension type.
- For direct distribution, follow Developer ID signing, hardened runtime, notarization, and ticket stapling requirements for the artifact. Sign nested code correctly and test the delivered package on a clean machine; local development launch does not prove Gatekeeper behavior.
- Preserve the existing update channel. If updates are part of the task, verify authenticity, compatibility, and recoverable failure; don't add an updater dependency solely as a best-practice recommendation.

## Example

Keep authority alive and guarantee balanced cleanup for a resolved security-scoped URL:

```swift
import Foundation

enum FileAccessError: Error { case denied }

func withFileAccess<T>(
    to url: URL, perform operation: (URL) throws -> T
) throws -> T {
    guard url.startAccessingSecurityScopedResource() else {
        throw FileAccessError.denied
    }
    defer { url.stopAccessingSecurityScopedResource() }
    return try operation(url)
}
```

This helper is for security-scoped URLs; ordinary container URLs use their normal access path. Keep large synchronous I/O out of UI execution.

## Checklist

- [ ] Symbol availability and deployment target agree; beta APIs are identified.
- [ ] Window focus, scene restoration, and document ownership are explicit.
- [ ] File access, cleanup, denial, and save conflicts are handled.
- [ ] Helpers and distribution use the intended entitlements and lifecycle.
- [ ] Relevant sandbox, UI, and distribution checks ran when authorized; limits are stated.

## References

- [Xcode/SDK matrix](https://developer.apple.com/xcode/system-requirements)
- [Security-scoped access](https://developer.apple.com/documentation/foundation/url/startaccessingsecurityscopedresource())
- [SMAppService](https://developer.apple.com/documentation/servicemanagement/smappservice)
- [Notarization](https://developer.apple.com/documentation/security/notarizing-macos-software-before-distribution)
- [Distribution testing](https://developer.apple.com/documentation/xcode/packaging-mac-software-for-distribution)
- [Liquid Glass](https://developer.apple.com/videos/play/wwdc2025/219/)

Wersje

W bazie nie ma innych skilli o nazwie programming-osx.

Migawka bazy z 13.11.2026 · wersja paczki 7be5ead3a81d (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 90desktop-swiftui
    Pomaga w tworzeniu aplikacji SwiftUI dla macOS: wzorce desktopowe, mostkowanie z AppKit i cykl życia aplikacji.
  • 90macos
    Wspiera budowę aplikacji na Maca: menu bar extras, zarządzanie oknami, integrację z AppKit i notaryzowaną dystrybucję poza App Store.
  • 90desktop-appkit
    Pomaga w tworzeniu aplikacji macOS w AppKit i Cocoa, w tym w Swift AppKit i architekturze natywnych aplikacji Mac.
  • 100macos-apps
    Buduje natywne aplikacje macOS w Swift ze SwiftUI i AppKit, obejmując budowanie, debugowanie, testy, optymalizację i wydanie, wyłącznie z wiersza poleceń bez Xcode.
  • 91macos-design-guidelines
    Opiera projektowanie aplikacji macOS w SwiftUI lub AppKit na wytycznych Apple Human Interface Guidelines, w tym menu, toolbary, zarządzanie oknami i skróty.
  • 100appkit-app-architecture-workflow
    Prowadzi decyzje o strukturze aplikacji AppKit na macOS: delegaty, aplikacje paska menu, łańcuch responderów, okna, kontrolery, archiwizacja i mieszanie AppKit z SwiftUI.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.