Skip to main content 首页 创作者 ajbcoding claude-skill-eval moai-lang-swift
moai-lang-swift Swift 6.0 enterprise development with async/await, SwiftUI, Combine, and Swift Concurrency. Advanced patterns for iOS, macOS, server-side Swift, and enterprise mobile applications with Context7 MCP integration.
跳到安装 Skills Marketplace 发现并探索由社区构建的 Agent Skills
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/AJBcoding/claude-skill-eval --skill moai-lang-swift命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
下载 Zip 下载中... Enterprise-grade security expertise with production-ready patterns for OWASP Top 10 2021, zero-trust architecture, threat modeling (STRIDE, PASTA), secure SDLC, DevSecOps automation, cloud security, cryptography, identity & access management, and compliance frameworks (SOC 2, ISO 27001, GDPR, CCPA).
name moai-lang-swift version 4.0.0 created 2025-10-22T00:00:00.000Z updated 2025-11-12T00:00:00.000Z status stable description Swift 6.0 enterprise development with async/await, SwiftUI, Combine, and Swift Concurrency. Advanced patterns for iOS, macOS, server-side Swift, and enterprise mobile applications with Context7 MCP integration. keywords ["swift","swiftui","async-await","swift-concurrency","combine","ios","macos","server-side-swift","context7"] allowed-tools ["Read","Bash","mcp__context7__resolve-library-id","mcp__context7__get-library-docs"]
Swift - Enterprise v4.0.0
Metadata
Field Value Skill Name moai-lang-swift Version 4.0.0 (2025-11-12) Allowed tools Read, Bash, Context7 MCP Auto-load On demand when keywords detected Tier Language Enterprise Context7 Integration ✅ Swift/SwiftUI/Vapor/Combine
What It Does
Swift 6.0 enterprise development featuring modern concurrency with async/await, SwiftUI for declarative UI, Combine for reactive programming, server-side Swift with Vapor, and enterprise-grade patterns for scalable, performant applications. Context7 MCP integration provides real-time access to official Swift and ecosystem documentation.
Key capabilities :
✅ Swift 6.0 with strict concurrency and actor isolation
✅ Advanced async/await patterns and structured concurrency
✅ SwiftUI 6.0 for declarative UI development
✅ Combine framework for reactive programming
✅ Server-side Swift with Vapor 4.x
✅ Enterprise architecture patterns (MVVM, TCA, Clean Architecture)
✅ Context7 MCP integration for real-time docs
✅ Performance optimization and memory management
✅ Testing strategies with XCTest and Swift Testing
✅ Swift Concurrency with actors and distributed actors
When to Use
Automatic triggers :
Swift 6.0 development discussions
SwiftUI and iOS/macOS app development
Async/await and concurrency patterns
Combine reactive programming
Server-side Swift and Vapor development
Enterprise mobile application architecture
Manual invocation :
Design iOS/macOS application architecture
Implement async/await patterns
Optimize performance and memory usage
Review enterprise Swift code
Implement reactive UI with Combine
Troubleshoot concurrency issues
Technology Stack (2025-11-12)
Component Version Purpose Status
Swift 6.0.1 Core language ✅ Current SwiftUI 6.0 Declarative UI ✅ Current Combine 6.0 Reactive programming ✅ Current Vapor 4.102.0 Server-side framework ✅ Current Xcode 16.2 Development environment ✅ Current Swift Concurrency 6.0 Async/await & actors ✅ Current Swift Testing 0.10.0 Modern testing framework ✅ Current
Quick Start: Hello Async/Await import Foundation
actor GreeterService {
func greet (name : String ) -> String {
"Hello, \(name) !"
}
}
Task {
let service = GreeterService ()
let greeting = await service.greet(name: "Swift" )
print (greeting)
}
Level 1: Quick Reference
Core Concepts
Async/Await - Modern concurrency without callbacks
Function marked with async - Suspends for I/O
Caller uses await - Waits for result
Native error handling with throws
Replaces callbacks and completion handlers
SwiftUI - Declarative UI framework
State-driven views update automatically
@State for local state
@StateObject for ViewModels
Composable views with modifiers
Combine - Reactive programming
Publishers emit values
Operators transform pipelines
Subscribers receive results
Error handling with .catch
Actors - Thread-safe state isolation
Protect mutable state automatically
Replace locks and semaphores
@MainActor for UI thread
Distributed actors for RPC
Vapor - Server-side Swift
Async route handlers
Database integration (Fluent)
Middleware for cross-cutting concerns
Type-safe API responses
Project Structure MyApp/
├── Sources/
│ ├── App.swift # Entry point
│ ├── Models/ # Data types
│ ├── Services/ # Business logic
│ ├── ViewModels/ # UI state management
│ └── Views/ # SwiftUI components
├── Tests/
│ ├── UnitTests/
│ └── IntegrationTests/
└── Package.swift # Dependencies
Level 2: Implementation Patterns
Async/Await Pattern import Foundation
func fetchData () async throws -> String {
let url = URL (string: "https://api.example.com/data" )!
let (data, _ ) = try await URLSession .shared.data(from: url)
return String (data: data, encoding: .utf8) ?? ""
}
func loadMultipleResources () async throws -> (String , String ) {
try await withThrowingTaskGroup(of: (String , String ).self ) { group in
group.addTask { ("users" , try await fetchUsers()) }
group.addTask { ("posts" , try await fetchPosts()) }
var results: [String : String ] = [:]
for try await (key, value) in group {
results[key] = value
}
return (results["users" ] ?? "" , results["posts" ] ?? "" )
}
}
SwiftUI State Management import SwiftUI
@MainActor
class ContentViewModel : ObservableObject {
@Published var items: [String ] = []
@Published var isLoading = false
func loadItems () async {
isLoading = true
defer { isLoading = false }
do {
items = try await fetchItems()
} catch {
items = []
}
}
}
struct ContentView : View {
@StateObject private var viewModel = ContentViewModel ()
var body: some View {
NavigationView {
VStack {
if viewModel.isLoading {
ProgressView ()
} else {
List (viewModel.items, id: \.self ) { item in
Text (item)
}
}
}
.navigationTitle("Items" )
.task {
await viewModel.loadItems()
}
}
}
}
Actor Isolation Pattern
actor CounterService {
private var count: Int = 0
func increment () { count += 1 }
func decrement () { count -= 1 }
func getCount () -> Int { count }
}
Task {
let counter = CounterService ()
await counter.increment()
let value = await counter.getCount()
}
Vapor Server Route import Vapor
func routes (_ app : Application ) throws {
app.get("api" , "users" ) { req async -> [String : String ] in
return ["status" : "success" ]
}
app.post("api" , "users" ) { req async -> HTTPStatus in
return .created
}
}
Level 3: Advanced Topics
Concurrency Best Practices
Prefer async/await over Combine for sequential operations
Use actors for mutable shared state (not locks)
Mark UI code @MainActor to ensure main thread
Handle cancellation properly in long-running tasks
Avoid blocking operations (no sleep, no synchronous I/O)
Performance Optimization
Memory : Use value types (struct) by default
CPU : Profile with Xcode Instruments
Rendering : Keep SwiftUI view body pure
Networking : Implement request caching
Database : Use connection pooling in Vapor
Security Patterns
Input validation : Always validate user input
Error handling : Don't expose internal errors to users
Encryption : Use CryptoKit for sensitive data
Authentication : Implement JWT or OAuth2
SQL injection prevention : Use parameterized queries
Testing Strategy
Unit tests : Pure functions with XCTest
Integration tests : Database and API tests
UI tests : SwiftUI view behavior
Mocking : Use protocols for dependency injection
Context7 MCP Integration Get latest Swift documentation on-demand:
from context7 import resolve_library_id, get_library_docs
swift_id = resolve_library_id("swift" )
docs = get_library_docs(
context7_compatible_library_id=swift_id,
topic="structured-concurrency" ,
tokens=5000
)
swiftui_id = resolve_library_id("swiftui" )
swiftui_docs = get_library_docs(
context7_compatible_library_id=swiftui_id,
topic="state-management" ,
tokens=4000
)
vapor_id = resolve_library_id("vapor" )
vapor_docs = get_library_docs(
context7_compatible_library_id=vapor_id,
topic="routing" ,
tokens=3000
)
Related Skills & Resources
Skill("moai-context7-lang-integration"): Latest Swift/Vapor documentation
Skill("moai-foundation-testing"): Swift testing best practices
Skill("moai-foundation-trust"): TRUST 5 principles application
Skill("moai-foundation-security"): Security patterns for Swift
Skill("moai-essentials-debug"): Swift debugging techniques
Troubleshooting Problem : Sendable conformance error
Solution : Implement Sendable protocol or use @Sendable closure
Problem : Actor isolation violation
Solution : Use nonisolated for safe properties or proper await calls
Problem : Memory leaks in closures
Solution : Capture [weak self] to break retain cycles
Problem : SwiftUI view not updating
Solution : Ensure state changes happen on @MainActor
Changelog
v4.0.0 (2025-11-12): Enterprise upgrade - Progressive Disclosure structure, 90% content reduction, Context7 integration
v3.0.0 (2025-03-15): SwiftUI 5.0 and Combine 6.0 patterns
v2.0.0 (2025-01-10): Basic Swift 5.x patterns
v1.0.0 (2024-12-01): Initial release
Resources For working examples : See examples.md
For API reference : See reference.md
For advanced patterns : See full SKILL.md in documentation archive
Last updated: 2025-11-12 | Maintained by moai-adk team