# How to Migrate from Segment's Retired Mobile SDKs to RudderStack's iOS (Swift) and Android (Kotlin) SDKs


> Twilio ended support for Analytics-iOS and Analytics-Android on March 31, 2026. Move to RudderStack's Swift and Kotlin SDKs and keep anonymous IDs.



Move your native iOS and Android apps from Segment's retired libraries to RudderStack's iOS (Swift) and Android (Kotlin) SDKs.

Twilio ended support for Segment's Analytics-iOS and Analytics-Android libraries on March 31, 2026. This guide, part of the [Segment to RudderStack Migration Guide](https://www.rudderstack.com/docs/user-guides/migration-guides/segment-rudderstack-migration/index.md), helps you install both SDKs, map each call, keep anonymous IDs, and keep old app versions sending data.

**Success:** RudderStack is the agentic, developer-first CDP. Its warehouse-native design makes your warehouse the system of record, the [Rudder CLI](https://www.rudderstack.com/docs/rudder-cli/index.md) manages your sources as code, and Claude, Codex, Cursor, or any MCP-enabled agent can monitor your pipelines through [RudderStack MCP](https://www.rudderstack.com/docs/ai-features/rudderstack-mcp/index.md).

## Twilio's end of support

Twilio's [February 23, 2026 notice](https://www.twilio.com/en-us/blog/products/sunsetting-legacy-segment-analytics-libraries) states that legacy Segment SDKs stopped receiving updates or support on March 31, 2026. That end of support affects both the libraries and any device mode destinations that depend on them. Events still reach Segment, but the libraries don't receive updates or bug fixes. Twilio's replacements, `Analytics-Swift` and `Analytics-Kotlin`, are new libraries too, so either path needs a new app release.

For device mode destinations, the iOS (Swift) and Android (Kotlin) SDKs run [Device Mode Integrations in Mobile SDKs](https://www.rudderstack.com/docs/sources/event-streams/sdks/device-mode-integrations/index.md) for Adjust, AppsFlyer, Braze, CleverTap, Facebook App Events, Firebase, and Sprig.

## Before you start

- [Sign up](https://app.rudderstack.com/signup) for RudderStack on the Free plan, which covers 250K events a month.
- Add an **iOS (Swift)** source and an **Android (Kotlin)** source in the dashboard, and note each write key and your data plane URL.
- If your app runs RudderStack's legacy iOS (Obj-C) or Android (Java) SDK, the [iOS (Obj-C) to iOS (Swift) SDK Migration Guide](https://www.rudderstack.com/docs/sources/event-streams/sdks/swift-sdk/migration-guide/index.md) and the [Android (Java) to Android (Kotlin) SDK Migration Guide](https://www.rudderstack.com/docs/sources/event-streams/sdks/kotlin-sdk/migration-guide/index.md) carry over `anonymousId`, `userId`, and traits.

**Info:** Your write key changes per source, but your data plane URL stays the same.

To keep the sources as code, define them with the Rudder CLI as [Event Stream Sources](https://www.rudderstack.com/docs/rudder-cli/event-stream-sources/index.md) of type `ios_swift` and `android_kotlin`, preview with `rudder-cli apply --dry-run`, then run `rudder-cli apply`:

```yaml
version: rudder/v1
kind: event-stream-source
metadata:
  name: ios-swift-source
spec:
  id: "ios-swift-source"
  type: "ios_swift"
  name: "iOS (Swift) Source"
  enabled: true
```

## Install the iOS (Swift) SDK

Follow the [iOS (Swift) SDK Quickstart](https://www.rudderstack.com/docs/sources/event-streams/sdks/swift-sdk/quickstart/index.md), which shows each step in Swift and Objective-C. The SDK supports iOS 15.0+, macOS 12.0+, tvOS 15.0+, and watchOS 8.0+, and its latest version is 2.3.0, released November 23, 2026. 

In Xcode, select **File** > **Add Package Dependencies...** and enter `https://github.com/rudderlabs/rudder-sdk-swift`, or add these lines to `Package.swift`:

```swift
// In your package's dependencies
.package(url: "https://github.com/rudderlabs/rudder-sdk-swift.git", from: "2.3.0")

// In your target's dependencies
.product(name: "RudderStackAnalytics", package: "rudder-sdk-swift")
```

Then initialize the SDK once. It doesn't use a singleton, so keep this `Analytics` instance for every call:

```swift
import RudderStackAnalytics

let config = Configuration(
    writeKey: "<WRITE_KEY>",
    dataPlaneUrl: "<DATA_PLANE_URL>"
)

let analytics = Analytics(configuration: config)
```

## Install the Android (Kotlin) SDK

Follow the [Android (Kotlin) SDK Quickstart](https://www.rudderstack.com/docs/sources/event-streams/sdks/kotlin-sdk/quickstart/index.md), which shows each step in Kotlin and Java. Add version 2.3.0 (November 19, 2026) to `build.gradle.kts`:

```kotlin
dependencies {
    implementation("com.rudderstack.sdk.kotlin:android:2.3.0")
}
```

**Warning:** The Android (Kotlin) SDK doesn&#39;t declare the `INTERNET` permission for you. Add `&lt;uses-permission android:name=&#34;android.permission.INTERNET&#34; /&gt;` to your app&#39;s `AndroidManifest.xml`.

Then initialize the SDK in your `Application` class:

```kotlin
import android.app.Application
import com.rudderstack.sdk.kotlin.android.Analytics
import com.rudderstack.sdk.kotlin.android.Configuration

class MyApplication : Application() {
    lateinit var analytics: Analytics

    override fun onCreate() {
        super.onCreate()
        analytics = Analytics(
            configuration = Configuration(
                writeKey = "WRITE_KEY",
                application = this,
                dataPlaneUrl = "DATA_PLANE_URL",
            )
        )
    }
}
```

## Map your Segment calls to RudderStack

Event names, traits, and properties stay the same. The [Mobile SDK APIs](https://www.rudderstack.com/docs/sources/event-streams/sdks/mobile-sdk-apis/index.md) take named parameters, and the Kotlin SDK builds traits and properties with `buildJsonObject` from kotlinx.serialization.

| Segment call | iOS (Swift) SDK | Android (Kotlin) SDK |
| :--- | :--- | :--- |
| `identify` | `analytics.identify(userId: "user_id", traits: ["email": "alex@example.com"])` | `analytics.identify(userId = "user_id", traits = buildJsonObject { put("email", "alex@example.com") })` |
| `track` | `analytics.track(name: "Order Completed", properties: ["revenue": 30.0, "currency": "USD"])` | `analytics.track(name = "Order Completed", properties = buildJsonObject { put("revenue", 30.0); put("currency", "USD") })` |
| `screen` | `analytics.screen(screenName: "Main Screen", category: "Main")` | `analytics.screen(screenName = "Main Screen", category = "Main")` |
| `group` | `analytics.group(groupId: "group_id", traits: ["key-1": "value-1"])` | `analytics.group(groupId = "group_id", traits = buildJsonObject { put("key-1", "value-1") })` |
| `alias` | `analytics.alias(newId: "Alias ID 1")` | `analytics.alias(newId = "Alias ID 1")` |
| `reset` | `analytics.reset()` | `analytics.reset()` |
| `flush` | `analytics.flush()` | `analytics.flush()` |

When `identify` gets a user ID that differs from the stored one, the SDK calls `reset()` first ([Identify API](https://www.rudderstack.com/docs/sources/event-streams/sdks/mobile-sdk-apis/identify/index.md)).

## Keep each user's anonymous ID

Users keep the anonymous ID that Segment's SDK stored, through RudderStack's `SetAnonymousIdPlugin`. This plugin from [Custom Plugin Use Cases in Mobile SDKs](https://www.rudderstack.com/docs/sources/event-streams/sdks/client-side-features/plugin-architecture/use-cases/index.md) replaces the SDK-generated anonymous ID in every event payload:

1. In the release that runs both SDKs, save Segment's ID on the device. On iOS, call `Analytics.shared().getAnonymousId()` ([Analytics-iOS](https://www.twilio.com/docs/segment/connections/sources/catalog/libraries/mobile/ios)) in a Swift file that imports only `Segment`, because both libraries name their client `Analytics`. On Android, call `com.segment.analytics.Analytics.with(context).getAnalyticsContext().traits().anonymousId()` ([Analytics-Android](https://www.twilio.com/docs/segment/connections/sources/catalog/libraries/mobile/android)).
2. Keep the saved value across app launches, so the ID stays the same after a later release removes Segment's SDK.
3. Add the plugin right after you initialize RudderStack.

On Android:

```kotlin
import com.rudderstack.sdk.kotlin.core.Analytics
import com.rudderstack.sdk.kotlin.core.internals.models.Event
import com.rudderstack.sdk.kotlin.core.internals.plugins.Plugin

class SetAnonymousIdPlugin(
    private val anonymousId: String
) : Plugin {

    override val pluginType: Plugin.PluginType = Plugin.PluginType.OnProcess

    override lateinit var analytics: Analytics

    override suspend fun intercept(event: Event): Event = replaceAnonymousId(event)

    private fun replaceAnonymousId(event: Event): Event {
        event.anonymousId = anonymousId
        return event
    }
}

// Right after the SDK is initialized, with the ID you saved from Segment's SDK
analytics.add(SetAnonymousIdPlugin(anonymousId = "<SEGMENT_ANONYMOUS_ID>"))
```

On iOS:

```swift
import Foundation
import RudderStackAnalytics

class SetAnonymousIdPlugin: Plugin {
    var pluginType: PluginType = .onProcess
    var analytics: Analytics?
    private let anonymousId: String

    init(anonymousId: String) {
        self.anonymousId = anonymousId
    }

    func setup(analytics: Analytics) {
        self.analytics = analytics
    }

    func intercept(event: any Event) -> (any Event)? {
        return replaceAnonymousId(event: event)
    }

    private func replaceAnonymousId(event: any Event) -> any Event {
        var updatedEvent = event
        updatedEvent.anonymousId = anonymousId
        return updatedEvent
    }
}

// Right after the SDK is initialized, with the ID you saved from Segment's SDK
analytics.add(plugin: SetAnonymousIdPlugin(anonymousId: "<SEGMENT_ANONYMOUS_ID>"))
```

**Info:** `analytics.anonymousId` still returns the SDK-generated ID, while every event carries the saved one. When a user logs out, or before you identify a different user, remove the plugin with `analytics.remove` and delete the saved Segment ID, then call `reset()`. Otherwise the plugin is added again with the old ID on the next launch.

## Keep old app versions sending data

Old app versions keep sending data through RudderStack's Segment source until users update. To set up the [Segment Source](https://www.rudderstack.com/docs/sources/event-streams/cloud-apps/segment/index.md):

1. In the RudderStack dashboard, add a **Segment** source and copy the **Webhook URL** from its **Settings** tab. Use a dedicated Segment source for legacy app versions.
2. In Segment, add a **Webhooks** destination with that URL, and point the Segment sources of your old app versions at it.
3. When the share of users on old versions reaches your threshold (often a few percent), close your Segment account. See [Migrate legacy app versions running the Segment SDK](https://www.rudderstack.com/docs/user-guides/migration-guides/segment-rudderstack-migration/advanced-migration/index.md#migrate-legacy-app-versions-running-the-segment-sdk).

RudderStack is fully Segment-compatible, so it doesn't modify the events it receives from Segment. They flow to the destinations you connect to the Segment source.

## Run Segment and RudderStack side by side

Run Segment and RudderStack side by side for a subset of users, compare the data, then cut over. [Incrementally migrate high-traffic applications](https://www.rudderstack.com/docs/user-guides/migration-guides/segment-rudderstack-migration/advanced-migration/index.md#incrementally-migrate-high-traffic-applications) describes this approach for high-traffic apps:

1. Load both SDKs for a subset of users, such as a region, a cohort, or a product area.
2. Check the events in [Live Events](https://www.rudderstack.com/docs/monitor/live-events/index.md), or ask your agent to stream them through RudderStack MCP, then compare event counts, property values, and user traits between the two warehouses with SQL.
3. Add more users while the data matches, then switch your primary data flow to RudderStack and remove Segment's SDK in a later release.

## FAQ

#### What should I use instead of Segment's retired mobile SDKs?

Twilio ended support for Segment's Analytics-iOS and Analytics-Android libraries on March 31, 2026. Use RudderStack's iOS (Swift) and Android (Kotlin) SDKs, both at version 2.3.0 in November 2026.

#### Do I have to rewrite my tracking calls?

You update each call, but not your tracking design. `identify`, `track`, `screen`, `group`, and `alias` keep their names, and event names, traits, and properties stay the same. The client object and the parameter labels change, and on Android you build traits and properties with `buildJsonObject` instead of Segment's `Traits` and `Properties` objects.

#### What happens to users on old app versions?

Old app versions keep sending data through RudderStack's Segment source until users update. Their events reach the same destinations as your new release.

#### Can I run Segment and RudderStack in parallel?

Yes. Send data to both for a subset of users before you cut over. See [Incrementally migrate high-traffic applications](https://www.rudderstack.com/docs/user-guides/migration-guides/segment-rudderstack-migration/advanced-migration/index.md#incrementally-migrate-high-traffic-applications).

#### Does it work for Objective-C or Java apps?

Yes. Both quickstarts show Objective-C and Java code next to Swift and Kotlin.

#### Do users keep their anonymous ID?

Yes. Users keep the anonymous ID that Segment's SDK stored, through RudderStack's `SetAnonymousIdPlugin`.

## Next steps

- [Phase 3: Test and Validate Your Migration](https://www.rudderstack.com/docs/user-guides/migration-guides/segment-rudderstack-migration/migration-testing-validation/index.md)
- [iOS (Swift) SDK Quickstart](https://www.rudderstack.com/docs/sources/event-streams/sdks/swift-sdk/quickstart/index.md)
- [Android (Kotlin) SDK Quickstart](https://www.rudderstack.com/docs/sources/event-streams/sdks/kotlin-sdk/quickstart/index.md)
- [Custom Plugin Use Cases in Mobile SDKs](https://www.rudderstack.com/docs/sources/event-streams/sdks/client-side-features/plugin-architecture/use-cases/index.md)
- [Segment to RudderStack Migration Guide](https://www.rudderstack.com/docs/user-guides/migration-guides/segment-rudderstack-migration/index.md)

