Cuppa Plugins

The Cuppa Plugin ecosystem provides modular, reusable functionality that can be easily integrated into your iOS applications.

Available Plugins

Core Plugins

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

  1. 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()
        }
    }
}
  1. 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:

  1. Define your configuration:
public struct MyPluginConfiguration: PluginConfiguration {
    public let apiKey: String
    public let enableLogging: Bool

    public var settings: [String: Any] {
        ["apiKey": apiKey, "enableLogging": enableLogging]
    }
}
  1. 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
    }
}
  1. Register and use:
try PluginRegistry.shared.register(
    MyPlugin.self,
    with: MyPluginConfiguration(apiKey: "key", enableLogging: true)
)

Next Steps

Found an issue with this page? Report it on GitHub