swiftui-core

Core SwiftUI patterns for macOS and iOS development including navigation (NavigationSplitView, NavigationStack), state management (@State, @Binding, @Environment, @Bindable with @Observable), the new customizable toolbar system (toolbar IDs, ToolbarSpacer, DefaultToolbarItem, searchToolbarBehavior, matchedTransitionSource, sharedBackgroundVisibility), styled text editing (TextEditor with AttributedString, AttributedTextSelection, transformAttributes, textFormattingDefinition), and layout patterns. Use when building any SwiftUI view, implementing navigation, managing state, creating toolbars, or building rich text editors. Corrects common LLM errors like using deprecated NavigationView, wrong state wrappers, and outdated toolbar APIs.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "swiftui-core" with this command: npx skills add makgunay/claude-swift-skills/makgunay-claude-swift-skills-swiftui-core

SwiftUI Core Patterns

Modern SwiftUI patterns for views, navigation, state, toolbars, and text editing.

Critical Constraints

  • NavigationView → ✅ NavigationSplitView (sidebar/detail) or NavigationStack (push/pop)
  • @StateObject → ✅ @State with @Observable classes (macOS 14+)
  • @ObservedObject → ✅ direct property or @Bindable for bindings
  • @EnvironmentObject → ✅ @Environment with custom key
  • toolbar { } without IDs for customizable toolbars → ✅ toolbar(id:) with ToolbarItem(id:)
  • ❌ Old .searchable without behavior → ✅ Add .searchToolbarBehavior(.minimize) for space efficiency
  • ❌ Plain String in TextEditor for rich text → ✅ Use AttributedString binding

Reference Index

FileWhen to Use
references/toolbars.mdCustomizable toolbars, search integration, spacers, transitions
references/text-editing.mdTextEditor + AttributedString, selection, formatting toolbar
references/attributed-string.mdAttributedString API, text alignment, line height, writing direction

Navigation Patterns

Sidebar + Detail (macOS preferred)

NavigationSplitView {
    List(selection: $selectedItem) {
        ForEach(items) { item in
            NavigationLink(value: item) { Label(item.name, systemImage: item.icon) }
        }
    }
    .navigationTitle("Items")
} detail: {
    if let selectedItem {
        DetailView(item: selectedItem)
    } else {
        ContentUnavailableView("Select an item", systemImage: "sidebar.left")
    }
}

Push Navigation (iOS preferred)

NavigationStack(path: $path) {
    List(items) { item in
        NavigationLink(value: item) { Text(item.name) }
    }
    .navigationDestination(for: Item.self) { item in
        DetailView(item: item)
    }
}

State Management Quick Reference

NeedmacOS 14+ / iOS 17+Older targets
View owns mutable state@State@State (value) / @StateObject (object)
View receives objectplain property@ObservedObject
View needs binding@Bindable var model@ObservedObject var model
Shared via environment@Environment(\.key)@EnvironmentObject
View-local value@State private var@State private var

Common Mistakes & Fixes

MistakeFix
NavigationView { }NavigationSplitView { } detail: { } or NavigationStack { }
.toolbar { ToolbarItem { } } for customizable.toolbar(id: "myToolbar") { ToolbarItem(id: "action") { } }
Using NavigationLink(destination:)Use NavigationLink(value:) + .navigationDestination(for:)
TextField for rich textTextEditor(text: $attributedString, selection: $selection)
.sheet(isPresented:) without transitionAdd .matchedTransitionSource + .navigationTransition(.zoom)

References

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

macos-permissions

No summary provided by upstream source.

Repository SourceNeeds Review
General

macos-app-structure

No summary provided by upstream source.

Repository SourceNeeds Review
General

liquid-glass

No summary provided by upstream source.

Repository SourceNeeds Review
General

global-hotkeys

No summary provided by upstream source.

Repository SourceNeeds Review