Skip to main content

Configuring the SDK

The Embrace.Options object used to initialize your Embrace client is the configuration object for the SDK. It allows you to customize Embrace's behavior in the SDK. Many of these arguments are optional and are not required to get your app up and running.

Configuration Options

Here is a convenience initializer of the Embrace.Options object from the recommended EmbraceIO product, with all configurations included:

Embrace.Options(
appId: "Your App ID",
appGroupId: "Your App Group ID",
platform: .default,
endpoints: Embrace.Endpoints(
baseURL: "baseURLString",
developmentBaseURL: "developmentBaseURLString",
configBaseURL: "configBaseURLString"
),
logLevel: .default,
export: OpenTelemetryExport(
spanExporter: JaegerSpanExporter(
serviceName: "jaegerServiceName",
collectorAddress: "jaegerCollectorAddress"
)
)
)

The configuration arguments here are:

  • appId: the App ID for your Embrace application. This is the only required field. This can be found in your dashboard.
  • appGroudId: the ID for the Apple App Group that your app belongs to, if any.
  • platform: the mobile platform that the current application is running in. .default points to iOS, but there are also options for Unity, ReactNative, and Flutter.
  • endpoints: the Embrace.Endpoints object that configure the endpoints the SDK can use to upload data and fetch remote configurations.
  • logLevel: the level of severity for Xcode console logs. Set to .none to turn off console logging.
  • export: an OpenTelemetryExport object that can export logs and traces to the backend of your choice.
info

If you are not an existing Embrace customer, you can still start the SDK by using NOEMB as your appId.

Additional arguments from the core Embrace.Options initializer may add flexibility with additional configuration for:

  • captureServices: out-of-the-box CaptureServices that automatically capture the mobile events that Embrace's SDK sends to the backend, like networking and memory warnings. You can extend the base CaptureService for new services that fit your use-case.
  • crashReporter: by default, an EmbraceCrashReporter.

Building for Different Releases

Building Embrace.Options in-code allows flexibility for changing the Embrace application you're working on. When initializing the SDK, you can provide different Embrace.Options at compile time to switch build configurations:

#if DEBUG
var embraceOptions: Embrace.Options {
return .init(
appId: "Your Debug App ID",
appGroupId: nil,
logLevel: .debug
)
}
#else
var embraceOptions: Embrace.Options {
return .init(
appId: "Your App ID",
appGroupId: nil
)
}
#endif