Skip to main content

Overview

As soon as your app launches, you need to configure the SDK with your API Key. You’ll receive your public API key from the Encore team to configure and identify your app.

Initialize Encore in Your App

Edit your main App struct to configure Encore at launch:
import SwiftUI
import Encore

@main
struct YourApp: App {
    init() {
        // Configure Encore with your API key
        Encore.shared.configure(apiKey: "pk_your_api_key_here")
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}
This configures a shared instance of Encore, the primary class for interacting with the SDK’s API. Make sure to replace pk_your_api_key_here with your public API key.
If you don’t have access to your API key, please contact your Encore representative.

Next Steps

Now that Encore is configured, you’re ready to: