Cuppa Plugins
The Cuppa Plugin ecosystem provides modular, reusable functionality that can be easily integrated into your iOS applications.
Available Plugins
Core Plugins
- CuppaTheme - Design system and theming
- CuppaAnalyticsPlugin - Multi-provider analytics tracking
- CuppaErrorHandlingPlugin - Comprehensive error reporting
- CuppaAuthPlugin - Authentication and session management
Plugin Architecture
All plugins implement the CuppaPlugin protocol from CuppaCore:
public protocol CuppaPlugin: Sendable {
associatedtype Configuration: PluginConfiguration
static var identifier: String { get }
static var version: String { get }
static var dependencies: [String] { get }
static func register(with configuration: Configuration) throws
}
Installation
Add the plugin package to your Package.swift:
dependencies: [
.package(url: "https://github.com/cuppa-platform/cuppa-plugins-ios", from: "1.0.0")
]
Then add specific plugin targets to your target dependencies:
.target(
name: "YourApp",
dependencies: [
.product(name: "CuppaAnalyticsPlugin", package: "cuppa-plugins-ios"),
.product(name: "CuppaAuthPlugin", package: "cuppa-plugins-ios")
]
)
Quick Start
- Register the plugin in your app's initialization:
import CuppaCore
import CuppaAnalyticsPlugin
@main
struct MyApp: App {
init() {
// Register analytics plugin
try? PluginRegistry.shared.register(
CuppaAnalyticsPlugin.self,
with: AnalyticsPluginConfiguration(
providers: [ConsoleAnalyticsProvider()],
enableDebugLogging: true
)
)
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
- Use the plugin in your code:
import CuppaAnalyticsPlugin
// Track events
await AnalyticsManager.shared.track(event: "screen_view", properties: [
"screen_name": "Home"
])
Creating Custom Plugins
To create your own plugin:
- Define your configuration:
public struct MyPluginConfiguration: PluginConfiguration {
public let apiKey: String
public let enableLogging: Bool
public var settings: [String: Any] {
["apiKey": apiKey, "enableLogging": enableLogging]
}
}
- Implement the plugin:
public struct MyPlugin: CuppaPlugin {
public static let identifier = "com.mycuppa.my-plugin"
public static let version = "1.0.0"
public static let dependencies: [String] = []
public static func register(with configuration: MyPluginConfiguration) throws {
// Plugin initialization logic
}
}
- Register and use:
try PluginRegistry.shared.register(
MyPlugin.self,
with: MyPluginConfiguration(apiKey: "key", enableLogging: true)
)
Next Steps
- Explore CuppaAnalyticsPlugin for event tracking
- Learn about CuppaAuthPlugin for authentication
- Implement CuppaErrorHandlingPlugin for robust error handling