Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

mobile-swift

БесплатноБез исполняемых скриптовНе проверен

Writes idiomatic modern Swift for iOS: Swift 6 strict concurrency (async/await, actors, @MainActor, Sendable, cancellation), value types, some vs any, typed…

ahmadhussain0335от ahmadhussain0335132 установки в других каталогах

Об этом скилле

Swift for iOS

Write Swift the way a senior iOS engineer would in Swift 6: data-race safe by construction, value types first, no crashes on unexpected input, SwiftUI views that stay small and cheap, and code split into packages with tests next to it.

When to use

  • Writing new Swift, SwiftUI or SwiftData code, or generating a feature from a ticket.
  • Refactoring or migrating older code: completion handlers, ObservableObject, NavigationView, Core Data, XCTest unit tests, Swift 5 language mode.
  • Fixing compiler errors such as "sending risks causing data races", "non-Sendable type", "main actor-isolated property can not be referenced".
  • Adding a local Swift package, a test target, a lint config, or a privacy manifest.

Not for: reviewing someone else's diff (use mobile-code-review), a security audit (use mobile-security), or choosing an app architecture (use mobile-mvvm, mobile-mvi).

Workflow

  1. Read the project settings before writing code.
    • Swift language mode, strict concurrency level, default actor isolation, minimum iOS version.
    • Package.swift files, existing lint and format configs, test framework in use.
  2. Match the deployment target. @Observable and SwiftData need iOS 17, Mutex needs iOS 18. Gate newer APIs with if #available or ask before raising the target.
  3. Load the reference for the area being touched: Concurrency, SwiftUI, SwiftData, Testing, Packages and tooling.
  4. Model data first: value types, explicit Sendable where it crosses isolation, typed errors where the set is closed.
  5. Decide isolation per type: @MainActor for UI-facing state, an actor for shared mutable state, nonisolated value types for everything else.
  6. Write the code, then the tests in the same change. Swift Testing for unit tests, XCTest only for UI and performance tests.
  7. Build with zero concurrency warnings, run the tests, run SwiftLint and the formatter.
  8. List every Info.plist key, entitlement, background mode and privacy manifest entry the change adds. These have signing and App Review consequences and must be called out explicitly.

Rules

1. Structs by default, final class only when identity matters

// BAD: reference semantics for plain data, shared mutation, not Sendable
class Reading { var value: Double; var date: Date }

// GOOD
struct Reading: Sendable, Equatable { let value: Double; let date: Date }

// GOOD: identity and lifetime matter (connection, cache, model observed by UI)
@MainActor @Observable
final class DeviceSession { var state: ConnectionState = .idle }
  • Classes are final unless subclassing is designed for.
  • let over var. Mutation happens through methods with clear names, not public setters.

2. No force unwraps, force casts or try! in app code

// BAD
let url = URL(string: base + path)!
let cell = tableView.dequeueReusableCell(withIdentifier: "c") as! DeviceCell

// GOOD
guard let url = URL(string: base + path) else { throw APIError.invalidURL(path) }
let name = device.name ?? String(localized: "Unknown device")
  • In tests use try #require(value) instead of !, so a nil fails the test instead of crashing the run.
  • A static literal URL may use a guard with preconditionFailure("...") and a message, never a bare !.

3. some when one concrete type is fixed, any only when it must vary at runtime

// BAD: existential box and dynamic dispatch for no reason
func render(_ items: any Collection<Reading>) -> any View

// GOOD: generic, specialised by the compiler
func render(_ items: some Collection<Reading>) -> some View

// GOOD: heterogeneous storage really needs an existential
var sinks: [any TelemetrySink]
  • Write any explicitly for every existential even where the compiler does not yet require it.
  • Primary associated types (some Collection<Reading>, any AsyncSequence<Int, Never>) instead of type-erasing wrappers.

4. Structured concurrency before unstructured Task {}

// BAD: unstructured tasks, no cancellation propagation, errors lost
Task { profile = try await api.profile() }
Task { devices = try await api.devices() }

// GOOD: both cancelled with the parent, errors propagate
async let profile = api.profile()
async let devices = api.devices()
state = .loaded(try await profile, try await devices)
  • Dynamic fan-out uses withThrowingTaskGroup; bound the width for large inputs.
  • Task {} only at an entry point from synchronous code (button action, delegate callback), and its handle is stored and cancelled when the owner goes away.
  • Task.detached needs a written reason.

5. UI-facing state is @MainActor, data crossing isolation is Sendable

// BAD: silences the checker, data race still possible
final class TokenStore: @unchecked Sendable { var token: String? }
Полный SKILL.md на ClawHub

Установить mobile-swift в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл mobile-swift?

Writes idiomatic modern Swift for iOS: Swift 6 strict concurrency (async/await, actors, @MainActor, Sendable, cancellation), value types, some vs any, typed throws, SwiftUI with @Observable, NavigationStack and stable identity, SwiftData, SPM modules and Swift Testing. Use when writing or refactoring Swift views, view models, services or packages, or fixing concurrency warnings and Swift 6 migration errors.

Как установить скилл mobile-swift?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл mobile-swift запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить mobile-swift с