How to Build iOS Apps

Опубликовано: 13 Май 2026
на канале: Will Blair
13
0

My custom cursor rules ⬇️

Code Style:
Use Swift 5.9+ features; prefer structs over classes
Follow protocol-oriented programming principles
Use descriptive camelCase variables, PascalCase types
Structure: controllers, views, models, extensions, helpers
Follow Apple's Human Interface Guidelines

Swift Best Practices:
Avoid force unwrapping (!); use if let/guard let
Use Result type for error handling
Leverage async/await over completion handlers
Use property wrappers appropriately (@State, @Published)
Apply guard for early returns and preconditions

UI Development:
Use SwiftUI for modern interfaces; UIKit when necessary
Implement responsive design with size classes
Use SF Symbols for consistent iconography
Support dynamic type and dark mode
Handle safe areas properly on all devices

Architecture:
Follow MVVM or coordinator pattern
Use Combine for reactive programming
CoreData for persistence, UserDefaults for simple storage
Implement proper dependency injection

Performance:
Lazy load resources not immediately needed
Use background threads for heavy computations
Profile with Instruments to identify bottlenecks
Optimize table/collection views with cell reuse
Watch for retain cycles; use weak/unowned references

Navigation:
Use NavigationView/UINavigationController consistently
Implement deep linking and universal links
Consider coordinator pattern for complex flows

Error Handling:
Create custom error types conforming to Error protocol
Use do/try/catch for error handling
Implement form validation with Codable
Log errors appropriately for debugging

Testing:
Write unit tests with XCTest
Implement UI tests with XCUITest
Use mocks/stubs for isolated testing
Consider snapshot testing for views

Security:
Use Keychain for sensitive data
Implement App Transport Security (ATS)
Use LocalAuthentication for biometric auth
Follow Apple's security guidelines

SwiftUI Specifics:
@State for view-local state
@Binding for passing mutable state
@ObservableObject/@Published for shared state
Create reusable ViewModifiers for styling
Implement custom animations for better UX

Optimization:
Use app thinning and on-demand resources
Optimize images with asset catalogs
Implement proper caching strategies
Monitor memory usage with Instruments

Documentation:
Use /// for Swift documentation comments
Document complex logic and public APIs
Keep documentation updated with code changes