﻿---
title: Get started with EDOT iOS
description: Set up the Elastic Distribution of OpenTelemetry iOS (EDOT iOS) to send data to Elastic.
url: https://www.elastic.co/elastic/docs-builder/docs/4519/reference/opentelemetry/edot-sdks/ios/getting-started
products:
  - APM Agent
  - Elastic Cloud Serverless
  - Elastic Distribution of OpenTelemetry SDK
  - Elastic Distribution of OpenTelemetry iOS
  - Elastic Observability
applies_to:
  - Serverless Observability projects: Generally available
  - Elastic Stack: Generally available
  - Elastic Distribution of OpenTelemetry iOS: Generally available
---

# Get started with EDOT iOS
Set up the Elastic Distribution of OpenTelemetry iOS (EDOT iOS) in your app and explore your app's data in Kibana.

## Requirements


| Requirement | Minimum version |
|-------------|-----------------|
| Swift       | 5.10            |
| iOS         | 16              |

You also need a reachable OpenTelemetry Protocol (OTLP) endpoint provided by an [Elastic Agent OTLP endpoint](https://docs-v3-preview.elastic.dev/elastic/docs-builder/docs/4519/reference/edot-collector/modes#edot-collector-as-gateway).

## Add the SDK dependency

Add EDOT iOS to your app using Swift Package Manager.

### Add the package in Xcode

To add EDOT iOS to an Xcode project:
1. In Xcode, select **File** → **Add Package Dependencies**.
2. Enter `https://github.com/elastic/apm-agent-ios.git` in the package URL field.
3. Select the version rule that matches your dependency policy.
4. Add the `ElasticApm` product to your application target.

Refer to Apple's [Adding package dependencies to your app](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app) guide for more information.

### Add the package in `Package.swift`

Add the package and the `ElasticApm` product to your target:
```swift
// swift-tools-version: 5.10

import PackageDescription

let package = Package(
  name: "MyApp",
  dependencies: [
    .package(
      url: "https://github.com/elastic/apm-agent-ios.git",
      from: "2.2.0"
    ),
  ],
  targets: [
    .target(
      name: "MyApp",
      dependencies: [
        .product(name: "ElasticApm", package: "apm-agent-ios"),
      ]
    ),
  ]
)
```


## Agent setup

Initialize EDOT iOS as early as possible in your app lifecycle. The following examples send data over OTLP/HTTP and authenticate with an APM agent key:
```swift
import ElasticApm
import Foundation

let configuration = AgentConfigBuilder()
  .withExportUrl(URL(string: "https://your-otlp-endpoint")!)
  .withApiKey("your-api-key")
  .build()

ElasticApmAgent.start(with: configuration)
```


### SwiftUI applications

For a SwiftUI app, initialize EDOT iOS from an application delegate:
```swift
import ElasticApm
import SwiftUI
import UIKit

final class AppDelegate: NSObject, UIApplicationDelegate {
  func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
  ) -> Bool {
    let configuration = AgentConfigBuilder()
      .withExportUrl(URL(string: "https://your-otlp-endpoint")!)
      .withApiKey("your-api-key")
      .build()

    ElasticApmAgent.start(with: configuration)
    return true
  }
}

@main
struct MyApp: App {
  @UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate

  var body: some Scene {
    WindowGroup {
      ContentView()
    }
  }
}
```


### UIKit applications

For a UIKit app, initialize EDOT iOS from `application(_:didFinishLaunchingWithOptions:)`:
```swift
import ElasticApm
import UIKit

@main
final class AppDelegate: UIResponder, UIApplicationDelegate {
  func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    let configuration = AgentConfigBuilder()
      .withExportUrl(URL(string: "https://your-otlp-endpoint")!)
      .withApiKey("your-api-key")
      .build()

    ElasticApmAgent.start(with: configuration)
    return true
  }
}
```


## Start sending telemetry

With EDOT iOS initialized, you can start sending telemetry to Elastic.

### Generate telemetry

The following example generates a span through [manual instrumentation](https://www.elastic.co/elastic/docs-builder/docs/4519/reference/opentelemetry/edot-sdks/ios/manual-instrumentation):
```swift
import OpenTelemetryApi

let tracer = OpenTelemetry.instance.tracerProvider.get(
  instrumentationName: "com.example.my-app"
)

let span = tracer.spanBuilder(spanName: "load-products").startSpan()
span.setAttribute(key: "app.screen", value: "products")

// Run the operation you want to measure.

span.end()
```

EDOT iOS can also generate telemetry on your behalf. For example, [URLSession instrumentation](/elastic/docs-builder/docs/4519/reference/opentelemetry/edot-sdks/ios/automatic-instrumentation#urlsession-instrumentation) creates spans for outgoing network requests without requiring manual span code.

## Visualize telemetry

The [iOS OpenTelemetry Assets](https://docs-v3-preview.elastic.dev/elastic/docs-builder/docs/4519/reference/otel_ios_dashboards) integration provides Kibana dashboards designed for telemetry from iOS applications. These dashboards provide an overview of application health and dedicated views for spans, crashes, sessions, and other iOS telemetry.
After your app has sent telemetry data, either [manually](https://www.elastic.co/elastic/docs-builder/docs/4519/reference/opentelemetry/edot-sdks/ios/manual-instrumentation) or [automatically](https://www.elastic.co/elastic/docs-builder/docs/4519/reference/opentelemetry/edot-sdks/ios/automatic-instrumentation), install the integration's content package to visualize it in Kibana.
<stepper>
  <step title="Install the content package">
    1. In Kibana, search for **iOS OpenTelemetry Assets** in the [global search field](https://docs-v3-preview.elastic.dev/elastic/docs-builder/docs/4519/explore-analyze/find-and-organize/find-apps-and-objects).
    2. Select the integration, then click **Install iOS OpenTelemetry Assets** and confirm the action to add the iOS dashboards to Kibana.
  </step>

  <step title="Explore your data in the dashboard">
    Once the content package is installed, open the **[iOS OTel] Application Overview** dashboard:
    1. In Kibana, search for **Dashboards** in the [global search field](https://docs-v3-preview.elastic.dev/elastic/docs-builder/docs/4519/explore-analyze/find-and-organize/find-apps-and-objects).
    2. Search for **iOS OTel** and open the **[iOS OTel] Application Overview** dashboard.
    3. Select your application in the **Applications** table of the **Overview** section.

    ![Application Overview Dashboard](https://www.elastic.co/elastic/docs-builder/docs/4519/reference/opentelemetry/edot-sdks/ios/images/span-visualization/application-overview-dashboard.png)
    The dashboard provides a high-level view of your app's health, including span performance, crash analysis, and session-level insights.
  </step>

  <step title="View trace waterfall details">
    To inspect individual span traces in detail, go to a panel that shows a list of spans in the dashboard
    and click **Explore in Discover** `app_discover`.
    ![Explore in Discover](https://www.elastic.co/elastic/docs-builder/docs/4519/reference/opentelemetry/edot-sdks/ios/images/span-visualization/explore-spans-in-discover.png)
    In Discover, click **Toggle dialog with details** `expand` to expand the details for one
    of the spans.
    ![Open span details](https://www.elastic.co/elastic/docs-builder/docs/4519/reference/opentelemetry/edot-sdks/ios/images/span-visualization/open-span-details.png)
    You'll see the trace waterfall UI, showing the full span hierarchy and timing. You can expand it to fullscreen and drill down into further details from there.
    ![Trace waterfall UI](https://www.elastic.co/elastic/docs-builder/docs/4519/reference/opentelemetry/edot-sdks/ios/images/span-visualization/trace-waterfall-ui.png)
  </step>
</stepper>


### Learn more

- [View crash details](https://docs-v3-preview.elastic.dev/elastic/docs-builder/docs/4519/reference/otel_ios_dashboards#viewing-details-from-a-crash) — Learn how to visualize and drill into iOS crash reports in the dashboard.
- [Troubleshoot dashboard issues](https://docs-v3-preview.elastic.dev/elastic/docs-builder/docs/4519/reference/otel_ios_dashboards#troubleshooting) — Find solutions to common issues with the Kibana dashboard experience.


## What's next?

- This guide uses the minimum configuration needed to initialize EDOT iOS. Refer to [Configuration](https://www.elastic.co/elastic/docs-builder/docs/4519/reference/opentelemetry/edot-sdks/ios/configuration) to customize connectivity, authentication, sampling, storage, and instrumentation.
- Review [Automatic instrumentation](https://www.elastic.co/elastic/docs-builder/docs/4519/reference/opentelemetry/edot-sdks/ios/automatic-instrumentation) to learn what EDOT iOS captures on your behalf.
- Use [Manual instrumentation](https://www.elastic.co/elastic/docs-builder/docs/4519/reference/opentelemetry/edot-sdks/ios/manual-instrumentation) to create spans, metrics, and logs for your app's business logic.
- If data does not appear in Kibana, refer to [Troubleshooting](https://docs-v3-preview.elastic.dev/elastic/docs-builder/docs/4519/troubleshoot/ingest/opentelemetry/edot-sdks/ios).