Full technical details in your project at
/docs/modules/Core.mdWhat’s new
- v2.2.0 — the localized error surface lives next to Core:
AppError.localizedUserMessage(en + es) is provided by the Localization package, and every UI error call site now displays it instead of the rawuserMessage. See the AI and Localization modules for how this threads through the app. - v2.0 —
DeepLinkBus(in Core) is@Observable. Consumers that used.onReceive($bus.latest)should migrate to.onChange(of: bus.latest). SwiftUI’s observation machinery does the rest. - Swift 6 strict concurrency across the package.
What You Get
- ✅ AppError enum - Maps all system errors to user-friendly messages
- ✅ AppLogger - OSLog-based with automatic PII redaction
- ✅ ResultOrError - Functional error handling patterns
- ✅ Theme types -
ThemeManagerwith aThemeenum (system, light, dark, aurora, obsidian) - ✅ Zero dependencies - Pure foundation layer
Key Components
AppError (Production Type)
Here’s a shortened version of the production enum from the boilerplate:localizedUserMessage is the localized counterpart to AppError.userMessage, supplied by the Localization package and used by every UI error call site.
Production Value:
- ✅ Auto-maps URLError, NSError, custom errors
- ✅ Preserves technical details for logging
- ✅ Provides actionable user messages
- ✅ Sendable for Swift 6 compatibility
- ✅ Equatable for testing
AppLogger
Structured logging with PII redaction:Logger; pass as category:):
AppLogger.networking- HTTP requestsAppLogger.ai- LLM interactionsAppLogger.ui- User interface eventsAppLogger.feature- Feature operationsAppLogger.storage- SwiftData / Keychain / persistenceAppLogger.notifications- Notification operationsAppLogger.auth- Authentication flowsAppLogger.payments- Subscriptions and purchases
AppLogger.subsystem is the shared subsystem identifier (a String), not a category.
Customization Examples
Add Custom Error Type
Add Custom Log Category
Key Files
| Component | Location |
|---|---|
| AppError | Packages/Core/Sources/Core/AppError.swift |
| AppLogger | Packages/Core/Sources/Core/AppLogger.swift |
| Diagnostics | Packages/Core/Sources/Core/Diagnostics/ |
Dependencies
- None - Core has zero dependencies (by design)
Used By
- ✅ All other modules (foundation layer)
- ✅ ViewModels (error handling)
- ✅ Services (logging)
Best Practices
Error Handling
Error Handling
- Always map errors to
AppError - Use specific error reasons
- Provide actionable user messages
- Log technical details separately
Logging
Logging
- Prefer
AppLoggeroverprint()in app code (print()is fine in#Previewblocks) - Choose appropriate log level
- Use correct category
- Redact PII automatically
Learn More
Full Documentation
Complete Core guide
Networking Module
Uses Core for errors and logging
Storage Module
Uses Core for error handling
Architecture
See how Core fits in
Test Coverage
95%+ - Core is foundational, so it carries some of the highest coverage in the codebase. Its tests run alongside everything else in the single workspace pass: ~598 tests across 12 package test targets (the 11 reusable packages plus theTestSupport test-infrastructure package) and the app test suites, all driven by one Boilerplate.xctestplan run.
Tests include:
- Error mapping scenarios
- Logger output verification
- PII redaction
