Native iOS SDK Integration
Install and initialize HealEUMKit in a native iOS application using an approved SDK artifact.
HealEUMKit provides OpenTelemetry-based distributed tracing for iOS applications. It captures HTTP requests, enriches them with approved non-sensitive operational attributes such as journeyName, appVersion, and environment, and exports traces to your observability backend.
Key Features#
| Feature | Description |
|---|---|
| Automatic HTTP Tracing | Intercepts all URLSession requests |
| W3C Trace Context | Injects traceparent and custom trace headers |
| Custom Attributes | Captures only explicitly allowlisted non-sensitive attributes |
| Device Information | Configurable capture of approved device and application attributes; location remains off unless explicitly enabled |
| Journey Tracking | Derives journey name from headers or URL path rules |
| OTLP Export | Sends traces to any OTLP-compatible backend |
iOS Prerequisites#
| Requirement | Version |
|---|---|
| iOS | 13.0+ |
| Xcode | 14.0+ |
| Swift | 5.0+ |
Step 1: Add the SDK#
Option A: Manual Integration (Recommended)
- Drag
HealEUMKit.xcframeworkinto your Xcode project. - Select your app target.
- Go to General → Frameworks, Libraries, and Embedded Content.
- Ensure
HealEUMKit.xcframeworkis set to Embed & Sign.
Your App Target
├── Frameworks
│ └── HealEUMKit.xcframework (Embed & Sign)
Package-manager installation
Use Swift Package Manager or CocoaPods only when your HEAL release supplies an approved repository URL and version. Do not copy placeholder package coordinates into a project.
Step 2: Configure Info.plist#
Optional: Location permission
Leave location capture disabled unless the application has an approved monitoring purpose, user notice or consent where required, retention controls, and a matching usage description. Add the minimum iOS permission only when that design is approved.
Use HTTPS
Configure an HTTPS collector endpoint with a trusted certificate. Do not use a loopback address for a collector running outside the app device or simulator, and do not enable broad App Transport Security exceptions.
Protect user data
Allowlist only the operational attributes approved for tracing. Do not capture authorization headers, cookies, payment data, request or response bodies, mobile numbers, customer identifiers, precise location, or other personal data unless a documented purpose, legal basis, consent where required, retention, and access controls are in place.
Step 3: Initialize the SDK#
Initialize the SDK as early as possible in your app lifecycle.
Choose sampling deliberately
The sampling_ratio: 1.0 values below are syntax examples, not production recommendations. Replace them with the deployment-approved ratio after validating telemetry volume, cost, and diagnostic coverage.
Option A: Using AppDelegate
import UIKit
import HealEUMKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Initialize HealEUM SDK
initializeHealEUM()
return true
}
private func initializeHealEUM() {
let config: [String: Any] = [
// Required: endpoint configuration
"heal_receiver_endpoint": "https://your-telemetry-endpoint.com/v1/traces",
"service_name": "YourApp-ios",
"environment": "prod",
// Required: custom variable keys (headers to capture)
"custom_variable_keys": ["journeyName", "appVersion", "deviceType", "environment"],
// Optional: constant attributes for every span
"custom_variables": [
"channel": "mobile",
"platform": "ios"
],
// Optional: journey tracking
"journey_header": "journeyName",
"journey_path_rules": [
"/login/": "Login",
"/upi/": "UPI Payment",
"/transfer/": "Bank Transfer",
"/balance/": "Balance Inquiry"
],
// Optional: trace context
"trace_id_key": "gt-id",
"inject_traceparent": true,
"sampling_ratio": 1.0,
// Optional: URLs to ignore
"ignore_urls": ["/v1/traces", "/health", "/metrics"],
// Optional: location capture
"enable_location_capture": false,
// Debug: enable for development only
"debug_log_injection": false
]
do {
try Heal.initSDK(config: config)
print("HealEUM SDK initialized successfully")
} catch {
print("HealEUM SDK initialization failed: \(error)")
}
}
}
Option B: Using SwiftUI App
import SwiftUI
import HealEUMKit
@main
struct YourApp: App {
init() {
initializeHealEUM()
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
private func initializeHealEUM() {
let config: [String: Any] = [
"heal_receiver_endpoint": "https://your-telemetry-endpoint.com/v1/traces",
"service_name": "YourApp-ios",
"environment": "prod",
"custom_variable_keys": ["journeyName", "appVersion", "environment"],
"inject_traceparent": true,
"sampling_ratio": 1.0
]
do {
try Heal.initSDK(config: config)
print("HealEUM SDK initialized successfully")
} catch {
print("HealEUM SDK initialization failed: \(error)")
}
}
}
Option C: Using SceneDelegate
import UIKit
import HealEUMKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(
_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions
) {
// Initialize SDK here if not done in AppDelegate
initializeHealEUMIfNeeded()
guard let _ = (scene as? UIWindowScene) else { return }
}
private func initializeHealEUMIfNeeded() {
// SDK initialization code...
}
}
Step 4: Pass Custom Headers#
The SDK captures custom attributes from HTTP request headers. Your app must pass these headers with each API request.
Using URLSession
var request = URLRequest(url: URL(string: "https://api.yourserver.com/endpoint")!)
request.httpMethod = "POST"
// Add custom headers for tracing
request.setValue("environment-12345", forHTTPHeaderField: "environment")
request.setValue("1.0.0", forHTTPHeaderField: "appVersion")
request.setValue("Login", forHTTPHeaderField: "journeyName")
request.setValue("iOS", forHTTPHeaderField: "deviceType")
URLSession.shared.dataTask(with: request) { data, response, error in
// Handle response
}.resume()
Using Alamofire
import Alamofire
let headers: HTTPHeaders = [
"environment": "production",
"journeyName": "Login",
"appVersion": "1.0.0",
"deviceType": "iOS"
]
AF.request("https://api.yourserver.com/endpoint", headers: headers)
.responseJSON { response in
// Handle response
}
Creating a custom headers helper
struct HealHeaders {
static var current: [String: String] {
return [
"environment": "production",
"journeyName": NavigationTracker.shared.currentJourney,
"appVersion": Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "unknown",
"deviceType": "iOS"
]
}
static func apply(to request: inout URLRequest) {
for (key, value) in current {
request.setValue(value, forHTTPHeaderField: key)
}
}
}
// Usage
var request = URLRequest(url: url)
HealHeaders.apply(to: &request)
Using URLSession with a custom configuration
class NetworkManager {
static let shared = NetworkManager()
private lazy var session: URLSession = {
let config = URLSessionConfiguration.default
config.httpAdditionalHeaders = [
"deviceType": "iOS",
"appVersion": Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "unknown"
]
return URLSession(configuration: config)
}()
func request(url: URL, additionalHeaders: [String: String] = [:]) {
var request = URLRequest(url: url)
// Add dynamic headers
for (key, value) in additionalHeaders {
request.setValue(value, forHTTPHeaderField: key)
}
session.dataTask(with: request) { data, response, error in
// Handle response
}.resume()
}
}