ios-app-builder
Create production-quality iOS applications following Apple's official guidance and modern Swift patterns. Use when building iOS apps with Swift, SwiftUI, MVVM, Swift Concurrency (actors, async/await), SwiftData, or multi-module projects. Triggers on requests to create iOS projects, screens, ViewModels, repositories, feature modules, actors, or iOS architecture patterns.
- License 许可
- MIT
- 最近更新
- 2026-09-09
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- ios-app-builder
- description
- Create production-quality iOS applications following Apple's official guidance and modern Swift patterns. Use when building iOS apps with Swift, SwiftUI, MVVM, Swift Concurrency (actors, async/await), SwiftData, or multi-module projects. Triggers on requests to create iOS projects, screens, ViewModels, repositories, feature modules, actors, or iOS architecture patterns.
02 资源文件 10
- 资产文件assets/templates/Package.swift.template2.7 KB
- 许可证LICENSE1.0 KB
- 参考文档README.md3.7 KB
- 参考文档references/actors.md29.9 KB
- 参考文档references/architecture.md13.4 KB
- 参考文档references/modularization.md7.5 KB
- 参考文档references/project-setup.md6.7 KB
- 参考文档references/swiftui-patterns.md18.9 KB
- 参考文档references/testing.md12.3 KB
- 脚本scripts/generate_feature.py7.2 KB
03 SKILL.md 正文
iOS Development
Build iOS applications following Apple's official architecture guidance, modern Swift concurrency patterns, and SwiftUI best practices.
Quick Reference
| Task | Reference File |
|---|---|
| Architecture layers (UI, Domain, Data) | architecture.md |
| SwiftUI patterns & navigation | swiftui-patterns.md |
| Swift Actors & concurrency | actors.md |
| Project & build configuration | project-setup.md |
| Project structure & modules | modularization.md |
| Testing approach | testing.md |
Workflow Decision Tree
Creating a new project?
→ Read project-setup.md for SPM and Xcode setup
→ Read modularization.md for module structure
→ Use templates in assets/templates/
Adding a new feature? → Create feature module following modularization.md → Follow patterns in architecture.md
Building UI screens? → Read swiftui-patterns.md → Create Route + Screen + ViewModel
Setting up data layer? → Read data layer section in architecture.md → Create Repository protocol + actor implementation + @ModelActor
Working with concurrency? → Read actors.md for actors, Sendable, async/await → Follow the actor decision tree
Writing tests? → Read testing.md → Use Swift Testing framework with protocol-based test doubles
Core Principles
- Offline-first: Local persistence (SwiftData) is source of truth, sync with remote
- Unidirectional data flow: Events flow down, data flows up
- Reactive streams: Use AsyncSequence/AsyncStream for all data exposure
- Modular by feature: Each feature is self-contained via Swift Package modules
- Testable by design: Use protocols and test doubles, no mocking libraries
- Actor-isolated concurrency: Use actors for shared mutable state, @MainActor for UI
Architecture Layers
┌─────────────────────────────────────────┐
│ UI Layer │
│ (SwiftUI Views + @Observable VMs) │
├─────────────────────────────────────────┤
│ Domain Layer │
│ (Use Cases - optional, for reuse) │
├─────────────────────────────────────────┤
│ Data Layer │
│ (Repositories + DataSources) │
└─────────────────────────────────────────┘
Module Types
App/ # App target - entry point, navigation, @main
Features/
├── FeatureName/
│ ├── Sources/ # Route, Screen, ViewModel
│ └── Tests/ # Feature tests
Core/
├── Model/ # Domain models (pure Swift structs)
├── Data/ # Repositories (protocols + actor implementations)
├── Database/ # SwiftData models, @ModelActor
├── Network/ # URLSession, API models, DTOs
├── Common/ # Shared utilities, extensions
├── UI/ # Reusable SwiftUI components
├── DesignSystem/ # Theme, colors, typography, SF Symbols
└── Testing/ # Test utilities, test doubles
Creating a New Feature
- Create feature module in
Features/MyFeature/ - Add target to
Package.swiftwith dependencies on Core modules - Create these files:
MyFeatureRoute.swift- Owns ViewModel (@State), handles navigationMyFeatureScreen.swift- Receives ViewModel (let), renders UIMyFeatureViewModel.swift- @MainActor @Observable with individual properties
Standard File Patterns
ViewModel Pattern
Expose individual properties — SwiftUI's @Observable tracks each property accessed per view, enabling granular re-renders. Avoid wrapping state in a single enum (that forces full re-renders).
@MainActor
@Observable
final class MyFeatureViewModel {
private(set) var items: [Item] = []
private(set) var isLoading = false
var errorMessage: String?
private let repository: MyRepository
init(repository: MyRepository) {
self.repository = repository
}
func onAppear() async {
isLoading = true
defer { isLoading = false }
do {
items = try await repository.getItems()
} catch {
errorMessage = error.localizedDescription
}
}
func deleteItem(id: String) async {
do {
try await repository.deleteItem(id: id)
items.removeAll { $0.id == id }
} catch {
errorMessage = error.localizedDescription
}
}
func refresh() async {
await onAppear()
}
}
Screen Pattern (Route/Screen Separation)
- Route creates and owns the ViewModel with
@State - Screen receives the ViewModel as
let— no wrapper needed, SwiftUI auto-tracks@Observable - For two-way bindings (TextField, Toggle), use
@Bindablelocally in the body
// Route: owns ViewModel via @State, connects navigation
struct MyFeatureRoute: View {
@State private var viewModel: MyFeatureViewModel
init(repository: MyRepository) {
viewModel = MyFeatureViewModel(repository: repository)
}
var body: some View {
MyFeatureScreen(viewModel: viewModel)
.task { await viewModel.onAppear() }
.refreshable { await viewModel.refresh() }
.navigationTitle("My Feature")
}
}
// Screen: receives ViewModel, reads properties directly
struct MyFeatureScreen: View {
let viewModel: MyFeatureViewModel
var body: some View {
List(viewModel.items) { item in
Text(item.name)
.swipeActions {
Button("Delete", role: .destructive) {
Task { await viewModel.deleteItem(id: item.id) }
}
}
}
.overlay {
if viewModel.isLoading && viewModel.items.isEmpty {
ProgressView()
}
}
.overlay {
if let error = viewModel.errorMessage, viewModel.items.isEmpty {
ContentUnavailableView(
"Error",
systemImage: "exclamationmark.triangle",
description: Text(error)
)
}
}
}
}
When to use a state enum instead: Use
enum UiStateonly for truly mutually exclusive states like onboarding flows (step1 | step2 | step3) or auth state (loggedIn | loggedOut), where you cannot show content and loading simultaneously.
Property Wrapper Decision (WWDC 2023)
| View role | Wrapper | Example |
|---|---|---|
| Creates the ViewModel | @State |
@State private var viewModel = MyVM() |
| Receives from parent | let (none) |
let viewModel: MyVM |
Needs $ bindings |
@Bindable |
@Bindable var viewModel = viewModel |
| Shared app-wide | @Environment |
@Environment(AppState.self) var appState |
Repository Pattern
// Protocol: defines contract, Sendable for cross-isolation use
protocol MyRepository: Sendable {
func getItems() async throws -> [MyModel]
func observeItems() -> AsyncStream<[MyModel]>
func updateItem(_ item: MyModel) async throws
func sync() async throws
}
// Implementation: actor for thread-safe shared state
actor OfflineFirstMyRepository: MyRepository {
private let persistence: MyPersistenceActor
private let network: NetworkClient
init(persistence: MyPersistenceActor, network: NetworkClient) {
self.persistence = persistence
self.network = network
}
func getItems() async throws -> [MyModel] {
try await persistence.fetchAll()
}
func observeItems() -> AsyncStream<[MyModel]> {
persistence.observeAll()
}
func updateItem(_ item: MyModel) async throws {
try await persistence.upsert(item)
}
func sync() async throws {
let remoteItems = try await network.fetchItems()
for item in remoteItems {
try await persistence.upsert(item.toDomainModel())
}
}
}
Key Dependencies
Swift 6+ (strict concurrency)
iOS 17+ (required for @Observable, SwiftData, #Preview)
SwiftData (persistence)
Swift Testing (unit tests)
XCTest (UI tests)
Build Configuration
Use Swift Package Manager for multi-module projects:
- Local package inside Xcode workspace
- Each feature and core module is a separate target
- Strict concurrency checking enabled (
-strict-concurrency=complete) - Swift 6 language mode
See project-setup.md for complete configuration.
04 同仓库更多 Skills
zustand-state-management
Production-tested setup for Zustand state management in React applications with TypeScript. This skill provides comprehensive patterns for building scalable, type-safe global state. Use when: setting up global state in React, migrating from Redux or Context API, implementing state persistence with localStorage, configuring TypeScript with Zustand, using slices pattern for modular stores, adding devtools middleware for debugging, handling Next.js SSR hydration, or encountering hydration errors, TypeScript inference issues, or persist middleware problems. Prevents 5 documented issues: Next.js hydration mismatches, TypeScript double parentheses syntax errors, persist middleware export errors, infinite render loops, and slices pattern type inference failures. Keywords: zustand, state management, React state, TypeScript state, persist middleware, devtools, slices pattern, global state, React hooks, create store, useBoundStore, StateCreator, hydration error, text content mismatch, infinite render, localStorage, sessionStorage, immer middleware, shallow equality, selector pattern, zustand v5
zetic-mlange
Help users integrate the ZETIC Melange (MLange) on-device AI SDK into Android (Kotlin/Java) and iOS (Swift) mobile apps. Use this skill whenever the user mentions Zetic, MLange, Melange, ZeticMLangeModel, ZeticMLangeLLMModel, ZeticMLangeHFModel, on-device NPU inference for mobile, or deploying ML models to Android/iOS with NPU acceleration. Also trigger when users ask about running LLMs on-device with GGUF quantization, mobile NPU model deployment, or converting PyTorch/ONNX models for mobile inference. Covers general model inference, LLM inference (streaming token generation), and HuggingFace model loading.
youtube-downloader
Download videos, audio, playlists, and channels from YouTube and 1000+ websites using yt-dlp. Supports quality selection, format conversion, subtitle download, playlist filtering, metadata extraction, thumbnail download, and batch operations. Use when downloading YouTube videos in any quality (4K, 8K, HDR), extracting audio as MP3/M4A/FLAC, downloading entire playlists/channels, getting subtitles in multiple languages, converting to specific formats, downloading live streams, archiving content, or batch processing multiple URLs. Optimized for reliability with automatic retries, rate limiting, and error handling.
wordpress-plugin-core
This skill provides comprehensive knowledge for WordPress plugin development, covering core patterns, security best practices, database interactions, hooks/filters, Settings API, custom post types, REST API, and AJAX. This skill should be used when creating WordPress plugins, troubleshooting security issues, implementing custom post types/taxonomies, building admin interfaces, or working with the WordPress database. Use when: Creating new WordPress plugins, implementing nonces/sanitization/escaping, working with $wpdb and prepared statements, building Settings API pages, registering custom post types or taxonomies, implementing REST API endpoints, handling AJAX requests, debugging plugin activation/deactivation issues, preventing SQL injection/XSS/CSRF vulnerabilities. Keywords: wordpress plugin development, wordpress security, wordpress hooks, wordpress filters, wordpress database, wpdb prepare, sanitize_text_field, esc_html, wp_nonce, custom post type, register_post_type, settings api, rest api, admin-ajax, wordpress sql injection, wordpress xss, wordpress csrf, plugin header, activation hook, deactivation hook, wordpress coding standards, wordpress plugin architecture
webapp-testing
Test local web applications with Playwright. Use when asked to verify frontend functionality, debug UI behavior, capture browser screenshots, or inspect browser logs.
web-performance-audit
Audit web performance using Chrome DevTools MCP. Use when asked to audit, profile, debug, or optimize page load performance, Lighthouse scores, or site speed.