swift expert
4
总安装量
0
周安装量
#48548
全站排名
安装命令
npx skills add https://github.com/willsigmon/sigstack --skill Swift Expert
Skill 文档
Swift Expert
Swift and SwiftUI expertise for Leavn app.
Binding Fixes
Problem: $viewModel.property errors
Fix: Add @Bindable wrapper in View:
@Bindable var viewModel: MyViewModel
Actor Isolation (Swift 6)
@MainActorfor UI-touching codenonisolatedfor pure functionsTask { @MainActor in }for async UI updates- Never access @MainActor properties in deinit
@Observable Migration
Old: @Published var x + ObservableObject
New: @Observable class + plain var x
View: @State var vm = ViewModel() (not @StateObject)
SwiftUI Anti-Patterns
- Heavy computation in View body â Extract to ViewModel
- @State for reference types â Use @StateObject/@State with @Observable
- Missing @MainActor on ViewModels â Add it
- Force unwrapping in Views â Use nil coalescing
Common Compiler Errors
- “Cannot convert” â Check Optional unwrapping
- “Actor-isolated” â Add @MainActor or nonisolated
- “Missing conformance” â Add protocol or use type erasure
- “Ambiguous” â Add explicit type annotation
Use when: Swift errors, SwiftUI bugs, migration issues, best practices