swift-expert by 404kidwiz/claude-supercode-skills
npx skills add https://github.com/404kidwiz/claude-supercode-skills --skill swift-expert提供 Apple 生态系统开发专业知识,专注于使用 Swift 6、SwiftUI 和现代并发模式开发原生 iOS/macOS/visionOS 应用程序。构建高性能原生应用程序,实现跨 Apple 平台的深度系统集成。
场景: 使用现代 SwiftUI 重写一个遗留的 UIKit 应用程序。
实现:
结果:
场景: 将基于回调的代码转换为 async/await。
实现:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
结果:
场景: 优化缓慢的启动时间和卡顿的滚动。
实现:
结果:
在以下情况请勿调用:
mobile-app-developerbash 或 python-progame-developer(尽管 Metal/SceneKit 在范围内)目标: 管理一个线程安全的缓存,无需锁。
步骤:
定义 Actor
actor ImageCache {
private var cache: [URL: UIImage] = [:]
func image(for url: URL) -> UIImage? {
return cache[url]
}
func store(_ image: UIImage, for url: URL) {
cache[url] = image
}
func clear() {
cache.removeAll()
}
}
用法(异步上下文)
class ImageLoader {
private let cache = ImageCache()
func load(url: URL) async throws -> UIImage {
if let cached = await cache.image(for: url) {
return cached
}
let (data, _) = try await URLSession.shared.data(from: url)
guard let image = UIImage(data: data) else {
throw URLError(.badServerResponse)
}
await cache.store(image, for: url)
return image
}
}
用例: 将服务注入到 SwiftUI 层次结构中。
// 1. 定义 Key
private struct AuthKey: EnvironmentKey {
static let defaultValue: AuthService = AuthService.mock
}
// 2. 扩展 EnvironmentValues
extension EnvironmentValues {
var authService: AuthService {
get { self[AuthKey.self] }
set { self[AuthKey.self] = newValue }
}
}
// 3. 使用
struct LoginView: View {
@Environment(\.authService) var auth
func login() {
Task { await auth.login() }
}
}
用例: 将导航逻辑与视图解耦。
@Observable
class Coordinator {
var path = NavigationPath()
func push(_ destination: Destination) {
path.append(destination)
}
func pop() {
path.removeLast()
}
func popToRoot() {
path.removeLast(path.count)
}
}
enum Destination: Hashable {
case detail(Int)
case settings
}
用例: 创建一个自定义 DSL 来配置 API 请求。
@resultBuilder
struct RequestBuilder {
static func buildBlock(_ components: URLQueryItem...) -> [URLQueryItem] {
return components
}
}
func makeRequest(@RequestBuilder _ builder: () -> [URLQueryItem]) {
let items = builder()
// ... 构造 URL
}
// 用法
makeRequest {
URLQueryItem(name: "limit", value: "10")
URLQueryItem(name: "sort", value: "desc")
}
swift-openapi-generator。HStack/VStack 进行复制。每周安装
85
仓库
GitHub 星标
42
首次出现
2026年1月24日
安全审计
安装于
opencode76
gemini-cli71
codex71
claude-code70
cursor67
github-copilot64
Provides Apple ecosystem development expertise specializing in native iOS/macOS/visionOS applications using Swift 6, SwiftUI, and modern concurrency patterns. Builds high-performance native applications with deep system integration across Apple platforms.
Scenario: Rewriting a legacy UIKit app in modern SwiftUI.
Implementation:
Results:
Scenario: Converting callback-based code to async/await.
Implementation:
Results:
Scenario: Optimizing a slow startup time and janky scrolling.
Implementation:
Results:
Do NOT invoke when:
mobile-app-developerbash or python-progame-developer (though Metal/SceneKit is in scope)Goal: Manage a thread-safe cache without locks.
Steps:
Define Actor
actor ImageCache {
private var cache: [URL: UIImage] = [:]
func image(for url: URL) -> UIImage? {
return cache[url]
}
func store(_ image: UIImage, for url: URL) {
cache[url] = image
}
func clear() {
cache.removeAll()
}
}
Usage (Async context)
class ImageLoader {
private let cache = ImageCache()
func load(url: URL) async throws -> UIImage {
if let cached = await cache.image(for: url) {
return cached
}
let (data, _) = try await URLSession.shared.data(from: url)
guard let image = UIImage(data: data) else {
throw URLError(.badServerResponse)
}
await cache.store(image, for: url)
return image
}
}
Use case: Injecting services into the SwiftUI hierarchy.
// 1. Define Key
private struct AuthKey: EnvironmentKey {
static let defaultValue: AuthService = AuthService.mock
}
// 2. Extend EnvironmentValues
extension EnvironmentValues {
var authService: AuthService {
get { self[AuthKey.self] }
set { self[AuthKey.self] = newValue }
}
}
// 3. Use
struct LoginView: View {
@Environment(\.authService) var auth
func login() {
Task { await auth.login() }
}
}
Use case: Decoupling navigation logic from Views.
@Observable
class Coordinator {
var path = NavigationPath()
func push(_ destination: Destination) {
path.append(destination)
}
func pop() {
path.removeLast()
}
func popToRoot() {
path.removeLast(path.count)
}
}
enum Destination: Hashable {
case detail(Int)
case settings
}
Use case: Creating a custom DSL for configuring API requests.
@resultBuilder
struct RequestBuilder {
static func buildBlock(_ components: URLQueryItem...) -> [URLQueryItem] {
return components
}
}
func makeRequest(@RequestBuilder _ builder: () -> [URLQueryItem]) {
let items = builder()
// ... construct URL
}
// Usage
makeRequest {
URLQueryItem(name: "limit", value: "10")
URLQueryItem(name: "sort", value: "desc")
}
swift-openapi-generator.HStack/VStack to replicate.Weekly Installs
85
Repository
GitHub Stars
42
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode76
gemini-cli71
codex71
claude-code70
cursor67
github-copilot64
Swift Actor 线程安全持久化:构建离线优先应用的编译器强制安全数据层
1,700 周安装