Documentation Index
Fetch the complete documentation index at: https://docs.prism.byescaleira.com/llms.txt
Use this file to discover all available pages before exploring further.
PrismFoundation is the base layer of the Prism SDK. Every other module depends on it, but it has no dependencies of its own—so you can adopt it in any Swift target without pulling in additional code. It covers the core primitives that recur throughout every Apple-platform app: structured data models, logging, analytics, locale management, persistence helpers, and typed error handling.
Installation
Entities
PrismEntity is the base protocol for all data models in Prism. Conforming to it gives your struct Codable, Equatable, Hashable, CustomStringConvertible, and structured logging support in one declaration.
PrismEntity values also conform automatically, so [User] supports .log() without any extra code.
Logging
Prism uses two logging protocols built on top ofos.Logger.
PrismLogger adds a single log() method to any type. Call it when you want to emit the current value to the system log.
PrismSystemLogger is for concrete loggers that own a Logger instance and expose info, warning, and error methods. All built-in Prism modules use a PrismSystemLogger internally, so your logs stay consistent with the framework’s output in Console.app.
Analytics
PrismAnalyticsProvider is a provider-agnostic protocol for analytics backends. Implement it once and Prism’s UI components emit structured events to your backend automatically.
PrismAnalyticsEvent is a Sendable value type with a name, string parameters, and a timestamp. Prism ships pre-built event factories for common interactions:
| Factory | Event name | Parameters |
|---|---|---|
.buttonTap(label:testID:) | button_tap | label, test_id |
.screenView(name:route:) | screen_view | screen_name, route |
.fieldInteraction(testID:action:) | field_interaction | test_id, action |
.carouselScroll(testID:index:) | carousel_scroll | test_id, index |
.tabSelect(testID:tab:) | tab_select | test_id, tab |
.menuAction(testID:action:) | menu_action | test_id, action |
.custom(_:parameters:) | any string | any [String: String] |
Locale
PrismLocale is an enumeration of eight supported locales with built-in formatting, currency, calendar, and right-to-left information:
PrismLocaleManager. It’s an @Observable class that you inject into your app’s environment. Changing current propagates to all PrismUI components in the hierarchy, and the selection is persisted to UserDefaults by default.
User defaults
PrismDefaults wraps UserDefaults with full Codable type support and automatic JSON encoding and decoding.
prism.defaults suite name by default, keeping your app’s keys separate from standard defaults.
Date and number formatting
PrismDateFormatter is a protocol that wraps DateFormatter and hooks into PrismLocale.current automatically. Implement it to build locale-aware formatters with minimal boilerplate:
Error types
PrismError extends Error with LocalizedError, CustomStringConvertible, and PrismLogger. The default log() implementation emits the error description, failure reason, and recovery suggestion to separate log levels automatically:
Bundle and file helpers
PrismBundle reads app metadata from Bundle.main.infoDictionary:
PrismFileManager resolves paths in the Documents directory and supports public and private storage compartments. Pass .private to automatically create an isolated subdirectory: