apple-swift

Apple platform development with Swift 6, SwiftUI, async/await, and performance. Use when working with .swift files, Package.swift, Xcode projects, or building for iOS/macOS/watchOS/visionOS.

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 "apple-swift" with this command: npx skills add maroffo/claude-forge/maroffo-claude-forge-apple-swift

ABOUTME: Apple platform guide - Swift 6, SwiftUI, concurrency, testing, performance

ABOUTME: Modern Swift (2025-2026): @Observable, SwiftData, NavigationStack, strict concurrency

Apple Platform Development

Quick Reference

# Build
xcodebuild -scheme MyApp -sdk iphoneos build
xcodebuild -scheme MyApp -sdk macosx build

# Tests
xcodebuild test -scheme MyApp -destination 'platform=iOS Simulator,name=iPhone 16'

# SwiftLint / SPM
swiftlint lint [--fix]
swift build && swift test && swift package resolve

# ast-grep
sg --pattern '@Observable final class $NAME { $$$ }' --lang swift
sg --pattern '@MainActor' --lang swift

See also: _AST_GREP.md, _PATTERNS.md, source-control, references/


Swift 6

  • Strict concurrency - Data-race safety at compile time
  • @Observable - Replaces ObservableObject
  • @MainActor - UI thread isolation
  • Sendable - Safe cross-actor value types
  • Macros - @Observable, @Model, #Preview

Migration: Enable swiftLanguageModes: [.v6], replace ObservableObject, add @MainActor to UI classes, add Sendable to value types, use actors for shared state, replace callbacks with async throws.

For detailed migration patterns, see references/swift6-patterns.md.


SwiftUI

Property Wrappers

WrapperUse
@StateView-owned values, @Observable
@BindingTwo-way to parent
@BindableTwo-way to @Observable props
@EnvironmentSystem/app values
@StateObjectView-owned ObservableObject (legacy)

View property order: @Environment, let, @State/@Binding, computed, init, body, private methods

View sizing: <100 lines = single view; 100-200 = extract subviews; >200 = multiple files; business logic = @Observable VM; network/DB = repository pattern

For NavigationStack, SwiftData, MVVM, and DI patterns, see references/swiftui-patterns.md.


Concurrency

Common Fixes

ErrorFix
Main actor isolationAdd @MainActor to class/func
Non-isolated accessMark nonisolated
Sendable violationAdd @unchecked Sendable or fix
Protocol asyncRequire async in protocol
Closure captureUse @Sendable closure

When to use what

Use CaseChoice
One-shot networkasync/await
Parallel fetchesasync let / TaskGroup
Real-time streamsCombine / AsyncStream
UI events, debounceCombine

For MainActor, parallel execution, and actor patterns, see references/concurrency-patterns.md.


Architecture

MVVM with @Observable: @Observable @MainActor final class VM with private(set) properties, injected service protocols, async load methods with defer { isLoading = false }.

DI: Protocol-based with EnvironmentKey for SwiftUI injection.

Testing (Swift Testing, iOS 18+): @Suite, @Test, #expect. Parameterized with arguments:. Mock via protocol injection.

For full code examples, see references/swiftui-patterns.md and references/swift6-patterns.md.


Review Checklists

Concurrency: MainActor for UI, Sendable for cross-actor data, task cancellation handled, no data races (Swift 6)

SwiftUI: @Observable not ObservableObject (iOS 17+), NavigationStack not NavigationView, .task not .onAppear + Task, LazyVStack for long lists

CRITICAL: Force unwrap without safety, UI updates off MainActor, data races, retain cycles

HIGH: ObservableObject when @Observable available, NavigationView instead of NavigationStack


Detailed References

  • references/swift6-patterns.md - Swift 6 migration, Sendable, actors, macros
  • references/swiftui-patterns.md - NavigationStack, SwiftData, MVVM, dependency injection
  • references/concurrency-patterns.md - async/await, TaskGroup, MainActor, actors, AsyncStream
  • references/performance.md - Optimization, Instruments profiling, memory management

Official: Swift | SwiftUI | SwiftData

Libraries: TCA | Snapshot Testing | SwiftLint

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.

Coding

clickup

No summary provided by upstream source.

Repository SourceNeeds Review
General

newsletter-digest

No summary provided by upstream source.

Repository SourceNeeds Review
General

rails

No summary provided by upstream source.

Repository SourceNeeds Review
General

react-nextjs

No summary provided by upstream source.

Repository SourceNeeds Review