SwiftUI モダン開発ガイドライン
SwiftUI開発のエキスパートルール。適切なアーキテクチャ、状態管理、アニメーション、アクセシビリティ。
You are an expert AI programming assistant specializing in SwiftUI development.
Project Architecture
Organize code with clear separation of concerns:
Sources/
App/ # App entry point and configuration
Views/
Home/ # Feature-specific views
Profile/ # Each with associated ViewModels
Shared/ # Reusable components
Models/ # Data structures and entities
Services/
Network/ # API client and networking
Persistence/ # Core Data, SwiftData, UserDefaults
Utilities/ # Extensions, constants, helpers
Resources/
Assets/ # Images, colors
Localization/ # Strings files
Tests/
UnitTests/
UITests/
Design Principles
- Use native SwiftUI components: List, NavigationStack, TabView, SF Symbols.
- Apply VStack, HStack, ZStack with Spacer and Padding for responsive layouts.
- Use LazyVGrid and LazyHGrid for grid layouts.
- Leverage GeometryReader for dynamic sizing when needed.
- Incorporate shadows, gradients, blurs, and custom shapes for visual polish.
- Use .animation() and withAnimation for smooth transitions.
- Implement haptic feedback for interactive elements.
State Management
- Use @State for local view state.
- Use @Binding for child view communication.
- Use @StateObject for view-owned observable objects.
- Use @EnvironmentObject for dependency injection.
- Use @Observable macro (iOS 17+) for modern observation.
- Minimize state; derive computed properties when possible.
Navigation
- Use NavigationStack with NavigationPath for programmatic navigation.
- Implement deep linking with URL handling.
- Use sheet() and fullScreenCover() for modal presentation.
- Implement proper navigation state restoration.
Performance
- Use LazyVStack/LazyHStack for large scrollable content.
- Implement proper image caching and loading.
- Use task {} for async work in views.
- Profile with Instruments for performance bottlenecks.
Accessibility
- Add proper accessibility labels and hints.
- Support Dynamic Type for text scaling.
- Implement VoiceOver navigation.
- Use semantic grouping with accessibilityElement(children:).
Code Quality
- Write clean, readable SwiftUI code.
- Use Swift's latest features and conventions.
- Follow Apple's Human Interface Guidelines.
- Maintain comprehensive SwiftUI previews for all views.
Refer to Apple's SwiftUI documentation and WWDC sessions for the latest patterns. こちらもおすすめ
Mobile カテゴリの他のルール
もっとルールを探す
CLAUDE.md、.cursorrules、AGENTS.md、Image Prompts の全 157 ルールをチェック。