Files
fidelity-ai-workspace/ai/context/ios/current-practices.md

63 lines
2.3 KiB
Markdown

# Current iOS And Swift Practices
## Goal
Keep Swift/iOS answers modern without turning the workspace into stale API documentation.
---
## Currentness Rule
For version-sensitive recommendations, verify against official sources before presenting as current best practice.
Prefer:
- Apple Developer Documentation
- Swift.org / docs.swift.org
- official WWDC materials when API behavior or migration guidance matters
Avoid relying only on memory for:
- newest SwiftUI APIs
- Observation / data-flow migration guidance
- Swift Testing availability or migration advice
- Swift concurrency behavior
- Xcode or iOS version-specific recommendations
---
## Stable Defaults
- Prefer simple, testable Swift over clever abstractions.
- Prefer structured concurrency over ad-hoc callback or detached-task patterns when the deployment target and codebase support it.
- Keep UI state changes on the main actor.
- Avoid recommending new APIs until deployment target and project constraints are known.
- For SwiftUI, separate pure view composition from side effects and navigation/workflow coordination.
- For testing, use the framework already adopted by the codebase unless the user explicitly asks about migration.
---
## Testing Guidance
- Apple positions Swift Testing as a modern option for unit tests in Xcode 16 and later.
- XCTest remains relevant, especially for UI tests, performance tests, and existing test suites.
- Do not recommend wholesale migration from XCTest unless the project constraints support it.
---
## SwiftUI Guidance
- Observation can be adopted incrementally; do not assume a project can immediately replace all `ObservableObject` usage.
- In SwiftUI code review, focus on data ownership, lifecycle, invalidation scope, navigation boundaries, and side effects.
- Avoid introducing `@StateObject`, `@ObservedObject`, `@State`, or `@Observable` recommendations without first identifying ownership and deployment constraints.
---
## Source Anchors
- SwiftUI documentation: `https://developer.apple.com/documentation/swiftui`
- Observation migration: `https://developer.apple.com/documentation/swiftui/migrating-from-the-observable-object-protocol-to-the-observable-macro`
- Swift Testing: `https://developer.apple.com/documentation/testing`
- XCTest: `https://developer.apple.com/documentation/xctest`
- Swift language: `https://developer.apple.com/swift/`