mobile-swift
БесплатноБез исполняемых скриптовНе проверенWrites idiomatic modern Swift for iOS: Swift 6 strict concurrency (async/await, actors, @MainActor, Sendable, cancellation), value types, some vs any, typed…
от 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
- Read the project settings before writing code.
- Swift language mode, strict concurrency level, default actor isolation, minimum iOS version.
Package.swiftfiles, existing lint and format configs, test framework in use.
- Match the deployment target.
@Observableand SwiftData need iOS 17,Mutexneeds iOS 18. Gate newer APIs withif #availableor ask before raising the target. - Load the reference for the area being touched: Concurrency, SwiftUI, SwiftData, Testing, Packages and tooling.
- Model data first: value types, explicit
Sendablewhere it crosses isolation, typed errors where the set is closed. - Decide isolation per type:
@MainActorfor UI-facing state, anactorfor shared mutable state,nonisolatedvalue types for everything else. - Write the code, then the tests in the same change. Swift Testing for unit tests, XCTest only for UI and performance tests.
- Build with zero concurrency warnings, run the tests, run SwiftLint and the formatter.
- List every
Info.plistkey, 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
finalunless subclassing is designed for. letovervar. 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
guardwithpreconditionFailure("...")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
anyexplicitly 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.detachedneeds 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? }
Установить 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), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic