﻿---
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/3764/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 or EDOT Collector gateway](https://docs-v3-preview.elastic.dev/elastic/docs-builder/docs/3764/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.0.2"
    ),
  ],
  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")
  .useConnectionType(.http)
  .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")
      .useConnectionType(.http)
      .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")
      .useConnectionType(.http)
      .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/3764/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/3764/reference/opentelemetry/edot-sdks/ios/automatic-instrumentation#urlsession-instrumentation) creates spans for outgoing network requests without requiring manual span code.

### Visualize telemetry

After your app sends spans:
1. In Kibana, go to **Observability** → **Applications** → **Services**.
2. Set the time range to include the telemetry you generated.
3. Select your app from the [Services inventory](https://docs-v3-preview.elastic.dev/elastic/docs-builder/docs/3764/solutions/observability/apm/services).
4. Open its traces and select a span to inspect its duration, attributes, events, and related spans.

You can also use [Discover](https://docs-v3-preview.elastic.dev/elastic/docs-builder/docs/3764/explore-analyze/discover) to search raw spans and log records, including mobile attributes such as `session.id`.

## 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/3764/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/3764/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/3764/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/3764/troubleshoot/ingest/opentelemetry/edot-sdks/ios).