Auto-Instrumentation Setup
This guide outlines the steps required to set up the Signals SDK in your Apple OS applications using Swift.
Learn how to connect an existing source, integrate dependencies, turn on Auto-Instrumentation, and verify that your setup captures and processes data as intended.
Auto-Instrumentation in public beta
Auto-Instrumentation is in public beta, and Segment is actively working on this feature. Some functionality may change before it becomes generally available.
Regional availability
Auto-Instrumentation isn’t supported in EU workspaces.
Step 1: Get your source write key
You need the writeKey from an existing Segment source. To find it:
- In your Segment workspace, go to Connections > Sources.
- Select your source.
- From the source’s overview tab, go to Settings > API Keys.
- Copy the
writeKeyshown in the code block.
Step 2: Add dependencies and initialization code
Next, add the Signals SDKs to your Swift applicatiion.
-
Use Swift Package Manager to add the Signals SDK from the following repository:
https://github.com/segment-integrations/analytics-swift-live.git -
Add the initialization code and configuration options:
See configuration options for a complete list.
```swift
// Configure Analytics with your settings
{... <analytics config>....}
// Set up the Signals SDK configuration
let config = Signals.Configuration(
writeKey: "<WRITE_KEY>", // Replace <WRITE_KEY> with the write key you previously copied
maximumBufferSize: 100,
useSwiftUIAutoSignal: true,
useNetworkAutoSignal: true
)
// Locate and set the fallback JavaScript file for edge functions
let fallbackURL = Bundle.main.url(forResource: "MyEdgeFunctions", withExtension: "js")
// Apply the configuration and add the Signals plugin
Signals.shared.useConfiguration(config)
Analytics.main.add(plugin: LivePlugins(fallbackFileURL: fallbackURL))
Analytics.main.add(plugin: Signals.shared)
```
Verify that you replaced <WRITE_KEY> with the actual write key you copied in Step 1.
SwiftUI projects
If your app is written in SwiftUI, you need to add a TypeAlias.swift file to your project that captures interaction and navigation Signals, like in this example:
import Foundation
import Signals
typealias Button = SignalButton
typealias NavigationStack = SignalNavigationStack
typealias NavigationLink = SignalNavigationLink
typealias TextField = SignalTextField
typealias SecureField = SignalSecureField
Step 3: Turn on Auto-Instrumentation in your source
Next, return to the source settings to turn on Auto-Instrumentation:
- Go to Connections > Sources.
- Select the source you used in Step 1.
- From the source’s overview tab, go to Settings > Advanced.
- Toggle Auto-Instrumention on.
Step 4: Verify and deploy events
After integrating the SDK and running your app, verify that Segment is collecting signals:
- In your Segment workspace, go to Connections > Sources and select the source you used for Auto-Instrumentation.
- In the source overview, look for the Event Builder tab. If the tab doesn’t appear:
- Make sure you’ve installed the SDK correctly.
- Reach out to your Segment CSM to confirm that your workspace has the necessary feature flags enabled.
- Launch your app in debug mode. This enables signal collection so you can see activity in the Event Builder.
- Use the app as a user would: navigate between screens, tap buttons, trigger network requests. Signals appear in real time as you interact with the app.
- In the Event Builder, find a signal and click Configure event to define a new event. After configuring the event, click Publish event rules.
Configuration options
Using the Signals Configuration object, you can control the destination, frequency, and types of signals that Segment automatically tracks within your application. The following table details the configuration options for Signals-Swift.
Option |
Required | Value | Description |
|---|---|---|---|
writeKey |
Yes | String | Source write key |
maximumBufferSize |
No | Integer | The number of signals to be kept for JavaScript inspection. This buffer is first-in, first-out. Default is 1000. |
relayCount |
No | Integer | Relays signals to Segment every Xth event. Default is 20. |
relayInterval |
No | TimeInterval | Relays signals to segment every X seconds. Default is 60. |
broadcasters |
No | SignalBroadcaster |
An array of broadcasters. These objects forward signal data to their destinations, like WebhookBroadcaster or DebugBroadcaster writing to the developer console. Default is SegmentBroadcaster. |
useUIKitAutoSignal |
No | Bool | Tracks UIKit component interactions automatically. Default is false. |
useSwiftUIAutoSignal |
No | Bool | Tracks SwiftUI component interactions automatically. Default is false. |
useNetworkAutoSignal |
No | Bool | Tracks network events automatically. Default is false. |
allowedNetworkHosts |
No | Array | An array of allowed network hosts. |
blockedNetworkHosts |
No | Array | An array of blocked network hosts. |
Next steps
This guide walked you through initial Signals SDK/Auto-Instrumentation setup. Next, read the Auto-Instrumentation Signals Implementation Guide, which dives deeper into Signals and offers example rules.
This page was last modified: 15 Oct 2025
Need support?
Questions? Problems? Need more info? Contact Segment Support for assistance!