skills/coding/coding-swift/SKILL.md
Swift 6: async/await/actors/Sendable, generics, property wrappers, result builders, SPM, testing
npx skillsauth add alphaonedev/openclaw-graph coding-swiftInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill equips the AI to assist with Swift 6 programming, focusing on modern features for iOS and macOS development, including concurrency, generics, and package management.
Use this skill for tasks involving Swift 6 code, such as building async/await-based apps, implementing actors for thread safety, or managing Swift Package Manager (SPM) dependencies in iOS/macOS projects. Apply it when existing code needs updates for Sendable conformance or generics enhancements.
To accomplish tasks, structure code with Swift 6 idioms: Use async functions for I/O operations, wrap shared state in actors, and leverage generics for collections. For SPM, edit Package.swift and run builds. Always check for Sendable conformance to avoid data races. When integrating with Xcode, compile projects using the Swift 6 toolchain by setting the compiler version in project settings.
swift build --configuration release from the project directory.swift test --enable-test-discovery in an SPM project.func fetchData() async throws -> Data { ... } and call it with Task { let data = try await fetchData() }.actor MyActor { var state: Int = 0; func update() { state += 1 } }.func swap<T>(_ a: inout T, _ b: inout T) { let temp = a; a = b; b = temp }.@propertyWrapper struct Clamped<Value: Comparable> { var wrappedValue: Value { ... } }.let package = Package(name: "MyApp", dependencies: [.package(url: "https://github.com/apple/swift-algorithms", from: "1.0.0")]).Integrate this skill by ensuring the Swift 6 toolchain is installed (e.g., via Xcode 15+). For external services, set auth via environment variables like $SWIFT_API_KEY for API calls in code, e.g., let apiKey = ProcessInfo.processInfo.environment["SWIFT_API_KEY"]. When combining with other skills, import Swift packages in Xcode by adding them in the "Swift Packages" tab. For concurrency, ensure actors are used in async contexts to avoid runtime errors.
Handle errors in Swift 6 by using do-catch blocks with async functions, e.g.:
do {
let result = try await someAsyncFunction()
} catch let error as NSError {
print("Error code: \(error.code)")
}
Check for Sendable errors by adding @Sendable to functions and fixing non-conforming closures. For SPM, parse build errors from swift build output, e.g., look for "error: dependency not found" and resolve by updating Package.swift. Always use guard statements for optionals to prevent crashes.
func fetchUser() async throws -> User { let url = URL(string: "https://api.example.com/user")!; let (data, _) = try await URLSession.shared.data(from: url); return try JSONDecoder().decode(User.self, from: data) }. Call it in a task: Task { do { let user = try await fetchUser(); print(user.name) } catch { print(error) } }.actor Counter { private var value = 0; func increment() { value += 1 } }. Use it like: let counter = Counter(); Task { await counter.increment(); print(await counter.value) } to ensure thread safety.tools
Root web development: project structure, tooling selection, deployment decisions
development
WebAssembly: Rust/Go/C to WASM, wasm-bindgen, Emscripten, WASM Component Model
development
Vue 3: Composition API script setup, Pinia, Vue Router 4, SFCs, Vite, Nuxt 3
tools
Tailwind CSS 4: utility classes, config, JIT, arbitrary values, darkMode, plugins, shadcn/ui