{"data":{"slug":"discovered-1398b07a8ca2bec6fcda754b72ff5a3818fcacb9a4425761","title":"Swift Expert","summary":"Builds iOS\/macOS\/watchOS\/tvOS applications, implements SwiftUI views and state management, designs protocol-oriented architectures, handles async\/await concurrency, implements actors for thread safety, and debugs Swift-specific issues. Use when building iOS\/macOS applications with Swift 5.9+, SwiftUI, or async\/await concurrency.","url":"https:\/\/skillshunter.net\/skills\/discovered-1398b07a8ca2bec6fcda754b72ff5a3818fcacb9a4425761","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-1398b07a8ca2bec6fcda754b72ff5a3818fcacb9a4425761","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-1398b07a8ca2bec6fcda754b72ff5a3818fcacb9a4425761.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-1398b07a8ca2bec6fcda754b72ff5a3818fcacb9a4425761\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before implementing, ensure Swift 5.9+ is used and validate the project configuration with `swift build`. For async\/await, avoid mixing completion handlers with async context. When using SwiftUI, prefer `@Observable` over `ObservableObject` for view models.","instructions":"---\nname: swift-expert\ndescription: Builds iOS\/macOS\/watchOS\/tvOS applications, implements SwiftUI views and state management, designs protocol-oriented architectures, handles async\/await concurrency, implements actors for thread safety, and debugs Swift-specific issues. Use when building iOS\/macOS applications with Swift 5.9+, SwiftUI, or async\/await concurrency. Invoke for protocol-oriented programming, SwiftUI state management, actors, server-side Swift, UIKit integration, Combine, or Vapor.\nlicense: MIT\nmetadata:\n  author: https:\/\/github.com\/Jeffallan\n  company: https:\/\/synergetic.solutions\n  version: \"1.1.0\"\n  domain: language\n  triggers: Swift, SwiftUI, iOS development, macOS development, async\/await Swift, Combine, UIKit, Vapor\n  role: specialist\n  scope: implementation\n  output-format: code\n  upstream-docs: https:\/\/www.swift.org\/documentation\/\n  baseline: \"Swift 5.9\"\n  related-skills: \"\"\n---\n\n# Swift Expert\n\n## Core Workflow\n\n1. **Architecture Analysis** - Identify platform targets, dependencies, design patterns\n2. **Design Protocols** - Create protocol-first APIs with associated types\n3. **Implement** - Write type-safe code with async\/await and value semantics\n4. **Optimize** - Profile with Instruments, ensure thread safety\n5. **Test** - Write comprehensive tests with XCTest and async patterns\n\n> **Validation checkpoints:** After step 3, run `swift build` to verify compilation. After step 4, run `swift build -warnings-as-errors` to surface actor isolation and Sendable warnings. After step 5, run `swift test` and confirm all async tests pass.\n\n## Reference Guide\n\nLoad detailed guidance based on context:\n\n| Topic | Reference | Load When |\n|-------|-----------|-----------|\n| Official docs | https:\/\/www.swift.org\/documentation\/ | An API or behaviour not covered here; read the docs for the version the project pins |\n| SwiftUI | `references\/swiftui-patterns.md` | Building views, state management, modifiers |\n| Concurrency | `references\/async-concurrency.md` | async\/await, actors, structured concurrency |\n| Protocols | `references\/protocol-oriented.md` | Protocol design, generics, type erasure |\n| Memory | `references\/memory-performance.md` | ARC, weak\/unowned, performance optimization |\n| Testing | `references\/testing-patterns.md` | XCTest, async tests, mocking strategies |\n\n## Code Patterns\n\n### async\/await \u2014 Correct vs. Incorrect\n\n```swift\n\/\/ \u2705 DO: async\/await with structured error handling\nfunc fetchUser(id: String) async throws -> User {\n    let url = URL(string: \"https:\/\/api.example.com\/users\/\\(id)\")!\n    let (data, _) = try await URLSession.shared.data(from: url)\n    return try JSONDecoder().decode(User.self, from: data)\n}\n\n\/\/ \u274c DON'T: mixing completion handlers with async context\nfunc fetchUser(id: String) async throws -> User {\n    return try await withCheckedThrowingContinuation { continuation in\n        \/\/ Avoid wrapping existing async APIs this way when a native async version exists\n        legacyFetch(id: id) { result in\n            continuation.resume(with: result)\n        }\n    }\n}\n```\n\n### SwiftUI State Management\n\n```swift\n\/\/ \u2705 DO: use @Observable (Swift 5.9+) for view models\n@Observable\nfinal class CounterViewModel {\n    var count = 0\n    func increment() { count += 1 }\n}\n\nstruct CounterView: View {\n    @State private var vm = CounterViewModel()\n\n    var body: some View {\n        VStack {\n            Text(\"\\(vm.count)\")\n            Button(\"Increment\", action: vm.increment)\n        }\n    }\n}\n\n\/\/ \u274c DON'T: reach for ObservableObject\/Published when @Observable suffices\nclass LegacyViewModel: ObservableObject {\n    @Published var count = 0  \/\/ Unnecessary boilerplate in Swift 5.9+\n}\n```\n\n### Protocol-Oriented Architecture\n\n```swift\n\/\/ \u2705 DO: define capability protocols with associated types\nprotocol Repository<Entity> {\n    associatedtype Entity: Identifiable\n    func fetch(id: Entity.ID) async throws -> Entity\n    func save(_ entity: Entity) async throws\n}\n\nstruct UserRepository: Repository {\n    typealias Entity = User\n    func fetch(id: UUID) async throws -> User { \/* \u2026 *\/ }\n    func save(_ user: User) async throws { \/* \u2026 *\/ }\n}\n\n\/\/ \u274c DON'T: use classes as base types when a protocol fits\nclass BaseRepository {  \/\/ Avoid class inheritance for shared behavior\n    func fetch(id: UUID) async throws -> Any { fatalError(\"Override required\") }\n}\n```\n\n### Actor for Thread Safety\n\n```swift\n\/\/ \u2705 DO: isolate mutable shared state in an actor\nactor ImageCache {\n    private var cache: [URL: UIImage] = [:]\n\n    func image(for url: URL) -> UIImage? { cache[url] }\n    func store(_ image: UIImage, for url: URL) { cache[url] = image }\n}\n\n\/\/ \u274c DON'T: use a class with manual locking\nclass UnsafeImageCache {\n    private var cache: [URL: UIImage] = [:]\n    private let lock = NSLock()  \/\/ Error-prone; prefer actor isolation\n    func image(for url: URL) -> UIImage? {\n        lock.lock(); defer { lock.unlock() }\n        return cache[url]\n    }\n}\n```\n\n## Constraints\n\n### MUST DO\n- Use type hints and inference appropriately\n- Follow Swift API Design Guidelines\n- Use `async\/await` for asynchronous operations (see pattern above)\n- Ensure `Sendable` compliance for concurrency\n- Use value types (`struct`\/`enum`) by default\n- Document APIs with markup comments (`\/\/\/ \u2026`)\n- Use property wrappers for cross-cutting concerns\n- Profile with Instruments before optimizing\n\n### MUST NOT DO\n- Use force unwrapping (`!`) without justification\n- Create retain cycles in closures\n- Mix synchronous and asynchronous code improperly\n- Ignore actor isolation warnings\n- Use implicitly unwrapped optionals unnecessarily\n- Skip error handling\n- Use Objective-C patterns when Swift alternatives exist\n- Hardcode platform-specific values\n\n## Output Templates\n\nWhen implementing Swift features, provide:\n1. Protocol definitions and type aliases\n2. Model types (structs\/classes with value semantics)\n3. View implementations (SwiftUI) or view controllers\n4. Tests demonstrating usage\n5. Brief explanation of architectural decisions\n\nMaintained by [@jeffallan](https:\/\/github.com\/jeffallan), Principal Consultant at [Synergetic Solutions](https:\/\/synergetic.solutions)\n\n[Documentation](https:\/\/jeffallan.github.io\/claude-skills\/skills\/language\/swift-expert\/)\n","use_cases":["Implement SwiftUI views with state management using @Observable","Design protocol-oriented architectures with associated types","Handle async\/await concurrency with structured error handling","Implement actors for thread safety and shared state management","Debug Swift-specific issues in iOS\/macOS\/watchOS\/tvOS applications"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/Jeffallan\/claude-skills\/blob\/a8be463010e2ca23afe00ea00773aea7128e8971\/plugin\/skills\/swift-expert\/SKILL.md","source_commit":"a8be463010e2ca23afe00ea00773aea7128e8971","license":null,"version":null,"listing_approved_at":"2026-11-29","created_at":"2026-11-28T18:48:08.000000Z","updated_at":"2026-11-29T10:53:27.000000Z","seo_title":"Swift Expert - iOS\/macOS Application Development with Swift 5.9+","seo_description":"A Swift expert who builds iOS\/macOS applications using Swift 5.9+, SwiftUI, async\/await, and protocol-oriented programming. Specializes in concurrency, actors, and state","seo_keywords":["Swift","SwiftUI","iOS development","macOS development","async\/await","Swift 5.9","protocol-oriented programming","actors in Swift"]}}