https://github.com/rudderlabs/rudder-sdk-swift
Swift SDK for iOS, macOS, watchOS, tvOS for RudderStack - the Customer Data Platform for Developers.
https://github.com/rudderlabs/rudder-sdk-swift
analytics ios macos mobile swift tvos watchos
Last synced: about 1 month ago
JSON representation
Swift SDK for iOS, macOS, watchOS, tvOS for RudderStack - the Customer Data Platform for Developers.
- Host: GitHub
- URL: https://github.com/rudderlabs/rudder-sdk-swift
- Owner: rudderlabs
- License: other
- Created: 2024-08-13T19:03:45.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2026-05-12T09:19:39.000Z (about 2 months ago)
- Last Synced: 2026-05-12T10:36:22.733Z (about 2 months ago)
- Topics: analytics, ios, macos, mobile, swift, tvos, watchos
- Language: Swift
- Homepage: https://www.rudderstack.com
- Size: 1.28 MB
- Stars: 2
- Watchers: 4
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
The Customer Data Platform for Developers
Website
·
Documentation
·
Community Slack
---
# RudderStack Swift SDK
The Swift SDK enables you to track customer event data from your iOS, macOS, tvOS, and watchOS applications and send it to your configured destinations via RudderStack.
## Table of Contents
- [Installing the Swift SDK](#installing-the-swift-sdk)
- [Initializing the SDK](#initializing-the-sdk)
- [Identifying users](#identifying-users)
- [Tracking user actions](#tracking-user-actions)
- [Integrations](#integrations)
- [Contact us](#contact-us)
- [Follow Us](#follow-us)
---
## Installing the Swift SDK
### Swift Package Manager
Add the SDK to your Swift project using Swift Package Manager:
1. In Xcode, go to `File > Add Package Dependencies`

2. Enter the package repository URL: `https://github.com/rudderlabs/rudder-sdk-swift` in the search bar.
3. Select the version you want to use

4. Select the target to which you want to add the package.
5. Finally, click on **Add Package**.

Alternatively, add it to your `Package.swift` file:
```swift
// swift-tools-version:5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "RudderStack",
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "RudderStack",
targets: ["RudderStack"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/rudderlabs/rudder-sdk-swift.git", .upToNextMajor(from: ""))
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "RudderStack",
dependencies: [
.product(name: "RudderStackAnalytics", package: "rudder-sdk-swift")
]),
.testTarget(
name: "RudderStackTests",
dependencies: ["RudderStack"]),
]
)
```
### Platform Support
The SDK supports the following platforms:
- iOS 15.0+
- macOS 12.0+
- tvOS 15.0+
- watchOS 8.0+
---
## Initializing the SDK
To initialize the RudderStack Swift SDK, add the Analytics initialization snippet to your application's entry point:
```swift
import RudderStackAnalytics
class AppDelegate: UIResponder, UIApplicationDelegate {
var analytics: Analytics?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Initialize the RudderStack Analytics SDK
let config = Configuration(
writeKey: "",
dataPlaneUrl: ""
)
self.analytics = Analytics(configuration: config)
return true
}
}
```
Replace:
- ``: Your project's write key from the RudderStack dashboard.
- ``: The URL of your RudderStack data plane.
## Identifying users
The `identify` API lets you recognize a user and associate them with their traits:
```swift
analytics?.identify(
userId: "1hKOmRA4el9Zt1WSfVJIVo4GRlm",
traits: [
"name": "Alex Keener",
"email": "alex@example.com"
]
)
```
## Tracking user actions
The `track` API lets you capture user events:
```swift
analytics?.track(
name: "Order Completed",
properties: [
"revenue": 30.0,
"currency": "USD"
]
)
```
---
## Integrations
RudderStack Swift SDK supports various third-party integrations that allow you to send your event data to external analytics and marketing platforms. These integrations are implemented as separate modules that you can include in your project as needed.
### Available Integrations
The following integrations are currently available:
- [Adjust](https://github.com/rudderlabs/integration-swift-adjust) - Send your event data to Adjust for product analytics
- [AppsFlyer](https://github.com/rudderlabs/integration-swift-appsflyer) - Send your event data to AppsFlyer for mobile attribution and analytics
- [Braze](https://github.com/rudderlabs/integration-swift-braze) - Send your event data to Braze for customer engagement
- [Firebase](https://github.com/rudderlabs/integration-swift-firebase) - Send your event data to Google Firebase Analytics
- [Facebook](https://github.com/rudderlabs/integration-swift-facebook) - Send your event data to Facebook for analytics and advertising
### Using Integrations
To use an integration, follow these steps:
1. Add the integration dependency to your project using Swift Package Manager
2. Initialize the RudderStack SDK as usual
3. Add the integration to your Analytics instance
Example with multiple integrations:
```swift
import RudderStackAnalytics
import RudderIntegrationAdjust
import RudderIntegrationFirebase
class AppDelegate: UIResponder, UIApplicationDelegate {
var analytics: Analytics?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Initialize the RudderStack Analytics SDK
let config = Configuration(
writeKey: "",
dataPlaneUrl: ""
)
self.analytics = Analytics(configuration: config)
// Add integrations
analytics?.add(plugin: AdjustIntegration())
analytics?.add(plugin: FirebaseIntegration())
// Add more integrations as needed
return true
}
}
```
---
## Contact us
For more information:
- Email us at [docs@rudderstack.com](mailto:docs@rudderstack.com)
- Join our [Community Slack](https://rudderstack.com/join-rudderstack-slack-community)
## Follow Us
- [RudderStack Blog](https://rudderstack.com/blog/)
- [Slack](https://rudderstack.com/join-rudderstack-slack-community)
- [Twitter](https://twitter.com/rudderstack)
- [YouTube](https://www.youtube.com/channel/UCgV-B77bV_-LOmKYHw8jvBw)