The Customer Data Platform for Developers
Website · Documentation · Community Slack
RudderStack's iOS SDK lets you track event data from your iOS and tvOS applications. After integrating the SDK, you will also be able to send these events to your preferred destinations such as Google Analytics, Amplitude, and more.
For detailed documentation on the iOS SDK, click here.
The iOS SDK is available through CocoaPods, Carthage, and Swift Package Manager (SPM).
To install the SDK, simply add the following line to your Podfile:
pod 'Rudder', '1.25.2'
For Carthage support, add the following line to your Cartfile
:
github "rudderlabs/rudder-sdk-ios" "v1.25.2"
Remember to include the following code in all
.m
and.h
files where you want to refer to or use the RudderStack SDK classes, as shown:
#import <Rudder/Rudder.h>
You can also add the RudderStack iOS SDK via Swift Package Mangaer, via one of the following two ways:
- Go to File - Add Package, as shown:
-
Enter the package repository (
git@github.com:rudderlabs/rudder-sdk-ios.git
) in the search bar. -
In Dependency Rule, select Up to Next Major Version and enter
1.25.2
as the value, as shown:
-
Select the project to which you want to add the package.
-
Finally, click on Add Package.
To leverage package.swift, use the following snippet in your project:
// swift-tools-version:5.5
// 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: "git@github.com:rudderlabs/rudder-sdk-ios.git", from: "1.25.2")
],
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: "Rudder", package: "rudder-sdk-ios")
]),
.testTarget(
name: "RudderStackTests",
dependencies: ["RudderStack"]),
]
)
To the initialize RSClient
, place the following code in your AppDelegate.m
file under the method didFinishLaunchingWithOptions
:
RSConfigBuilder *builder = [[RSConfigBuilder alloc] init];
[builder withDataPlaneUrl:<DATA_PLANE_URL>];
[RSClient getInstance:<WRITE_KEY> config:[builder build]];
A shared instance of RSClient
is accesible after the initialization by [RSClient sharedInstance]
.
[[RSClient sharedInstance] track:@"simple_track_event"];
[[RSClient sharedInstance] track:@"simple_track_with_props" properties:@{
@"key_1" : @"value_1",
@"key_2" : @"value_2"
}];
[[RSClient sharedInstance] screen:@"Main" properties:@{@"prop_key" : @"prop_value"}];
[[RSClient sharedInstance] identify:@"test_user_id"
traits:@{@"foo": @"bar",
@"foo1": @"bar1",
@"email": @"test@gmail.com"}
];
[[RSClient sharedInstance] group:@"sample_group_id"
traits:@{@"foo": @"bar",
@"foo1": @"bar1",
@"email": @"test@gmail.com"}
];
[[RSClient sharedInstance] alias:@"new_user_id"];
[[RSClient sharedInstance] reset];
For detailed documentation on the iOS SDK, click here.
We would love to see you contribute to this project. Get more information on how to contribute here.
RudderStack is a customer data platform for developers. Our tooling makes it easy to deploy pipelines that collect customer data from every app, website and SaaS platform, then activate it in your warehouse and business tools.
More information on RudderStack can be found here.
For more information on using the RudderStack iOS SDK, you can contact us or start a conversation on our Slack channel.