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

swift

/swift

Wspiera pisanie Swifta dla iOS, macOS i serwera: semantyka wartości, optionals, projekt protokołowy, structured concurrency z async/await i actors oraz zarządzanie stanem w SwiftUI.

Licencja
MIT
Ostatnia zmiana repozytorium
24.10.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
0
Przestarzałość

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

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Wspiera pisanie Swifta dla iOS, macOS i serwera: semantyka wartości, optionals, projekt protokołowy, structured concurrency z async/await i actors oraz zarządzanie stanem w SwiftUI.

Wyzwalacze z opisu

migrate this completion handler to async/awaitsendable warnings under strict concurrencyretain cycle in my closurewhere should this state live
Oryginalny opis (EN)

Use when writing Swift for iOS, macOS, or server-side. Covers value semantics, optionals, protocol-oriented design, structured concurrency with async/await and actors, and SwiftUI state management. Trigger on "migrate this completion handler to async/await", "sendable warnings under strict concurrency", "retain cycle in my closure", "where should this state live". Do not use for app architecture, navigation, or App Store submission — see the ios skill.

Jak działa

  1. Purpose
  2. When to Use
  3. Capabilities
  4. Inputs
  5. Outputs
  6. Workflow
  7. Best Practices
  8. Examples
  9. Notes
Sekcje z nagłówków SKILL.md, w oryginale · 85 linii, 512 słów
Podgląd SKILL.md
---
name: swift
description: Use when writing Swift for iOS, macOS, or server-side. Covers value semantics, optionals, protocol-oriented design, structured concurrency with async/await and actors, and SwiftUI state management. Trigger on "migrate this completion handler to async/await", "sendable warnings under strict concurrency", "retain cycle in my closure", "where should this state live". Do not use for app architecture, navigation, or App Store submission — see the ios skill.
metadata:
  category: languages
  version: 1.0.0
  tags: [swift, ios, concurrency, actors, swiftui]
---

# Swift

## Purpose

Write Swift that leans on value semantics and the concurrency model rather than fighting them: structs by default, actors for shared mutable state, and no force-unwrapping.

## When to Use

- Writing Swift for Apple platforms or server-side Swift.
- Migrating callback or Combine code to async/await.
- Resolving data-race warnings under strict concurrency checking.
- Designing SwiftUI state and view models.
- Diagnosing retain cycles and memory growth.

## Capabilities

- Value vs reference semantics and copy-on-write.
- Optional handling: `guard let`, optional chaining, `Result` types.
- Protocol-oriented design with associated types and generics.
- Structured concurrency: `async let`, task groups, actors, `Sendable`.
- SwiftUI: `@State`, `@Observable`, and unidirectional data flow.

## Inputs

- Source target, Swift version, minimum deployment target.
- Concurrency checking level (minimal, targeted, complete).

## Outputs

- Code free of force-unwraps and implicit unwrapped optionals.
- Concurrency that compiles cleanly under strict checking.
- View models with a single source of truth.

## Workflow

1. **Prefer structs** — Reach for a class only when identity or shared mutation is required.
2. **Eliminate optionals early** — Unwrap once at the boundary with `guard`; the rest of the function works with non-optionals.
3. **Isolate mutable state** — Any shared mutable state becomes an actor or is confined to the main actor.
4. **Model async explicitly** — Replace completion handlers with `async` functions; use task groups for concurrency.
5. **Gate** — Build with strict concurrency checking and treat warnings as errors.

## Best Practices

- `!` is a crash waiting for a user to find it. The only acceptable uses are IBOutlets and genuinely proven invariants with a comment.
- Capture lists (`[weak self]`) on every escaping closure that captures `self` in a class.
- Mark types `Sendable` deliberately; suppressing the warning with `@unchecked Sendable` requires a documented reason.
- SwiftUI views are cheap and disposable — put logic in the model, not the view body.
- Prefer `async let` for a fixed set of concurrent calls; use `TaskGroup` when the count is dynamic.
- Long-running work never runs on the main actor.

## Examples

**Actor-isolated cache with concurrent loading:**

```swift
actor ImageCache {
    private var cache: [URL: UIImage] = [:]
    private var inFlight: [URL: Task<UIImage, Error>] = [:]

    func image(for url: URL) async throws -> UIImage {
        if let cached = cache[url] { return cached }
        if let existing = inFlight[url] { return try await existing.value }

        let task = Task<UIImage, Error> {
            let (data, _) = try await URLSession.shared.data(from: url)
            guard let image = UIImage(data: data) else { throw CacheError.decodeFailed(url) }
            return image
        }
        inFlight[url] = task

        defer { inFlight[url] = nil }
        let image = try await task.value
        cache[url] = image
        return image
    }
}
```

## Notes

- The actor above deduplicates concurrent requests for the same URL — a common source of redundant network traffic in image-heavy screens.
- Strict concurrency checking is noisy on legacy code. Enable it target by target rather than repository-wide.
- `@Observable` (iOS 17+) replaces `ObservableObject` and only invalidates views that actually read the changed property.

Wersje

RepozytoriumWynikLicencja
Ta strona · nimadorostkar/Claude-Skills-collection100MIT
G1Joshi/Agent-Skills100MIT
appwrite/claude-plugin95BSD-3-Clause
claude-dev-suite/claude-dev-suite95MIT
clawic/skills90MIT
maragudk/fabrik86MIT
dkbnull/hello-skill86MIT

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

Pobrania w ostatnich 30 dniach: 1 · ranking

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

Podobne skille

  • 100swift-concurrency
    Wdraża async/await, Actors i structured concurrency w Swifcie dla aplikacji iOS i macOS.
  • 100swift-expert
    Buduje aplikacje na iOS, macOS, watchOS i tvOS: widoki i stan w SwiftUI, architektura protokołowa, async/await, actors i debugowanie problemów specyficznych dla Swifta.
  • 100swift-expert
    Buduje aplikacje iOS, macOS, watchOS i tvOS w Swift: widoki SwiftUI, zarządzanie stanem, architekturę protokołów i błędy specyficzne dla Swift.
  • 95lang-swift
    Pisze i przegląda nowoczesny Swift 6: opcjonale, typy wartości, protokoły, ARC i cykle silnych referencji, współbieżność oraz Swift Package Manager.
  • 100swift-conventions
    Wymusza konwencje Swift przy zmianach kodu iOS i macOS: Swift API Design Guidelines, typy wartościowe, brak force-unwraps, strict concurrency Swift 6 i czysty SwiftLint oraz swift-format.
  • 90ios-swift-concurrency
    Pomaga wdrażać async/await, zarządzanie Task, aktorów i wzorce reaktywne Combine w aplikacjach iOS.

Uwagi i zgłoszenia

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