SwiftUI Programming Skill
/SwiftUI Programming Skill
Pomaga w kompozycji widoków SwiftUI, stanie i Observation, nawigacji, układach adaptacyjnych, formularzach, dostępności i wydajności.
- Autor
- fal3 ↗
- Repozytorium
- claude-skills-collection ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 17.09.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 6
- Skrypty
- 2
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 17.09.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
- 2 skrypty w paczce. Przejrzyj je przed instalacją, bo Claude może je uruchomić.
Skrypty: examples/example_toggle.swift, examples/example_toolbar.swift
Co robi i kiedy
Pomaga w kompozycji widoków SwiftUI, stanie i Observation, nawigacji, układach adaptacyjnych, formularzach, dostępności i wydajności.
Oryginalny opis (EN)
Use when work involves SwiftUI view composition, state and Observation ownership, navigation, adaptive layout, toolbars, forms, SF Symbols, accessibility, previews, or SwiftUI-specific performance. Do not use for UIKit/AppKit-only work, general Swift language questions, or architecture and performance work that does not involve SwiftUI.
Jak działa
- Supported baseline
- Workflow
- State and Observation
- Composition and layout
- Navigation and toolbars
- Accessibility and Dynamic Type
- Performance
- SF Symbols
- Copy-ready examples
Podgląd SKILL.md
---
name: SwiftUI Programming Skill
description: Use when work involves SwiftUI view composition, state and Observation ownership, navigation, adaptive layout, toolbars, forms, SF Symbols, accessibility, previews, or SwiftUI-specific performance. Do not use for UIKit/AppKit-only work, general Swift language questions, or architecture and performance work that does not involve SwiftUI.
---
# SwiftUI Programming Skill
Build SwiftUI interfaces that are correct for the user's declared platforms and deployment targets. Ask for those targets when an API choice depends on them; never assume the newest SDK is deployable.
## Supported baseline
The primary examples use Xcode 15, Swift 5.9, and iOS/iPadOS 17 or macOS 14. SwiftUI itself supports older systems, but newer APIs need explicit availability handling:
| Need | Preferred API | Minimum | Compatibility path |
|---|---|---|---|
| Stack navigation | `NavigationStack` | iOS 16, macOS 13, tvOS 16, watchOS 9 | `NavigationView` remains valid for earlier targets |
| Observation | `@Observable` | iOS 17, macOS 14, tvOS 17, watchOS 10 | `ObservableObject` and `@StateObject` remain supported |
| Toolbars | `.toolbar` | iOS 14, macOS 11, tvOS 14, watchOS 7 | Put controls in the view hierarchy on earlier targets |
| Modern change handling | zero- or two-parameter `onChange` | iOS 17, macOS 14, tvOS 17, watchOS 10 | Use the one-parameter overload on earlier targets |
APIs from the OS 27 development cycle are beta material relative to the stable Xcode 26.6 toolchain. Discuss them only when explicitly requested, label them beta, and provide stable fallbacks plus `#available` gates.
## Workflow
1. Record Swift, Xcode, and every platform minimum.
2. Choose semantic system controls before custom controls.
3. Define state ownership and a stable identity model.
4. Choose navigation and layout from capabilities, not device-name guesses.
5. Add accessibility and Dynamic Type while composing the view.
6. Compile at the oldest supported targets; test large accessibility sizes and relevant input methods.
7. Profile before adding performance-specific wrappers or caches.
## State and Observation
- Use `@State` for view-owned value state.
- For a view-owned `@Observable` reference, store it in `@State` so SwiftUI owns its lifetime.
- Pass an injected observable model as a plain property when the view only reads it. Create `@Bindable` locally when the view needs bindings.
- Use `@Environment` for dependencies intentionally shared through a subtree.
- Keep UI-observed mutable models on `@MainActor` unless their isolation is deliberately designed otherwise.
- Do not copy derived state into another mutable property. Prefer a computed property.
```swift
import Observation
import SwiftUI
@MainActor
@Observable
final class ProfileModel {
var displayName = ""
}
struct ProfileEditor: View {
@State private var model = ProfileModel()
var body: some View {
@Bindable var model = model
TextField("Display name", text: $model.displayName)
}
}
```
For iOS 16 and earlier, use `ObservableObject` with `@StateObject` for view ownership and `@ObservedObject` for injection. That is a compatibility decision, not an anti-pattern.
## Composition and layout
- Extract subviews around meaningful responsibility, reuse, or independent state—not to force a presumed redraw boundary.
- Prefer flexible frames, stacks, grids, `ViewThatFits`, and size classes. Use `GeometryReader` only when the child genuinely needs the proposed size.
- Respect safe areas unless the visual treatment deliberately extends under system UI.
- Use semantic colors and text styles; avoid fixed text heights and one-line truncation for user content.
- Treat iPad multitasking, macOS window resizing, tvOS focus, watchOS glanceability, and visionOS volumes as distinct capabilities.
## Navigation and toolbars
- Model destinations with stable, `Hashable` route data when navigation is state-driven.
- Prefer `NavigationStack` at its supported minimum. Use `NavigationSplitView` for genuinely multi-column interfaces, with a compact fallback.
- Keep destination construction consistent: every destination receives the selected value it requires.
- Use semantic toolbar placements such as `.primaryAction`, `.confirmationAction`, and `.cancellationAction` where they express intent across platforms.
- Do not use iOS-only placements or modifiers in an ungated all-platform view.
See [the complete toolbar example](examples/example_toolbar.swift) and [prompt scenarios](examples/prompts.md).
## Accessibility and Dynamic Type
- Prefer `Button`, `Toggle`, `TextField`, `Label`, and other semantic controls.
- Label icon-only controls with their purpose. Hints describe the result of an action, not the gesture.
- Keep separate interactive controls as separate accessibility elements.
- Use semantic fonts (`.body`, `.headline`) or `@ScaledMetric`; do not claim that a fixed `.system(size:)` font scales.
- Preserve alternatives to color, adequate interactive sizes and spacing, Reduce Motion, and Differentiate Without Color.
## Performance
- First measure with Instruments on a release build and representative hardware.
- Give collection elements stable IDs. Never use array offsets as identity for mutable collections.
- `List` already creates rows lazily. Use `ScrollView` plus `LazyVStack` for layout/interaction behavior that `List` cannot provide, not as a blanket speed upgrade.
- A parent body evaluation does not mean every descendant is redrawn on screen. Keep `body` inexpensive, but do not promise that extracting a view creates an independent render boundary.
- Use SwiftUI's `.equatable()` or `EquatableView` only after measurement and only when equality fully represents visible output.
- Cancel asynchronous work when its owning view disappears or its input changes. `.task(id:)` is usually the clearest view-lifetime tool.
## SF Symbols
- Verify each symbol exists for the deployment target and choose a fallback for newer symbols.
- Use rendering modes and symbol effects only at their documented availability.
- Give decorative symbols no separate accessibility focus; label icon-only controls at the control level.
## Copy-ready examples
- [State-driven toggle](examples/example_toggle.swift)
- [Navigation and semantic toolbar actions](examples/example_toolbar.swift)
- [Example prompts](examples/prompts.md)
When a requested example spans architecture, accessibility, performance, or platform-specific behavior, keep this skill focused on the SwiftUI layer and route the other concerns to their dedicated guidance.
Pliki w paczce (6)
- README.md 1 KB
- SKILL.md 6 KB
- agents/openai.yaml 1 KB
- examples/example_toggle.swift 1 KB
- examples/example_toolbar.swift 1 KB
- examples/prompts.md 1 KB
Wersje
W bazie nie ma innych skilli o nazwie SwiftUI Programming Skill.
Migawka bazy z 13.11.2026 · wersja paczki 5e0f4c9c258f (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
- 90swiftui-code-review
Przegląda kod SwiftUI pod kątem kompozycji widoków, zarządzania stanem, wydajności i dostępności w plikach z widokami, @State, @Binding i @Observable. - 90neo-swift-ui
Pomaga budować, debugować i recenzować aplikacje i widoki SwiftUI dla iOS 16+: NavigationStack, Observation i przepływ stanu, kompozycja widoków, podglądy, wydajność, dostępność i architektura. - 100swiftui-macos
Pisze i przegląda kod SwiftUI dla macOS, z rozumieniem obserwacji, współbieżności, wydajności i mostkowania z AppKit. - 100swiftui-patterns
Opisuje wzorce architektury SwiftUI: stan z @Observable, kompozycja widoków, nawigacja i optymalizacja wydajności renderowania w aplikacjach iOS i macOS. - 100swiftui-patterns
Podpowiada wzorce architektury SwiftUI: stan przez Observable, kompozycję widoków, nawigację i wydajność renderowania w iOS i macOS. - 100swiftui-view-refactor
Refaktoryzuje i przegląda pliki widoków SwiftUI pod kątem spójnej struktury, wstrzykiwania zależności i użycia Observation, w tym bezpiecznej obsługi modeli widoków.