Learn about the breaking changes introduced in the iOS (Swift) SDK.
6 minute read
This document outlines the breaking changes introduced in the iOS (Swift) SDK when migrating from the legacy iOS (Obj-C) SDKiOS (Obj-C) refers to the legacy RudderStack iOS SDK. Note that it will be deprecated soon.
For new implementations, use the iOS (Swift) SDK instead.
.
Overview
The iOS (Swift) SDK is built from scratch while retaining the core functionalities of the iOS (Obj-C) SDKiOS (Obj-C) refers to the legacy RudderStack iOS SDK. Note that it will be deprecated soon.
For new implementations, use the iOS (Swift) SDK instead.
.
Note the following before upgrading your SDK:
This SDK does not support automatic data migration from the previous iOS (Obj-C) SDKiOS (Obj-C) refers to the legacy RudderStack iOS SDK. Note that it will be deprecated soon.
For new implementations, use the iOS (Swift) SDK instead.
.
Any data persisted by the iOS (Obj-C) SDK is not carried over automatically.
The iOS (Swift) SDK requires a higher minimum platform version (iOS 15.0+ vs iOS 12.0+).
SDK initialization
The way of initializing the iOS (Swift) SDK has changed. See the following snippets for comparison:
In the iOS (Swift) SDK, a RudderOption instance is created using constructor arguments:
letexternalId=ExternalId(type:"brazeExternalId",id:"some_external_id_1")letoption=RudderOption(integrations:["Amplitude":false],customContext:["customKey":["key":"value"]],externalIds:[externalId])lettraits=["name":"John","email":"john@example.com"]// Identify event is used just for demonstration purposes.analytics.identify(userId:"user123",traits:traits,options:option)
Other API changes
Method
iOS (Obj-C) — Legacy
iOS (Swift)
putIntegration
Accepts two arguments — type (String) and enabled (Boolean).
Converted into constructor arguments and renamed to integrations of a single Dictionary type.
putCustomContext
Accepts two arguments — type (String) and context (Dictionary).
Converted into constructor arguments and renamed to customContext of a single Dictionary type.
putExternalId
Accepts two arguments — type (String) and id (String).
Converted into constructor arguments and renamed to externalIds of type [ExternalId], where ExternalId is a class with a type (String) and id (String).
sharedInstance
Singleton pattern for accessing the client.
No singleton pattern - you manage the Analytics instance.
getInstance
Static method to initialize the client.
Direct initialization with Analytics(configuration:).
reset()
Deprecated method without parameters.
Replaced with reset() that always clears anonymousId.
reset:(BOOL)clearAnonymousId
Method with Boolean parameter to control anonymousId clearing.
Use a custom plugin to retain anonymousId if needed.
SDK configuration changes
The following table maps the SDK configuration options available in the iOS (Obj-C) SDK to the new iOS (Swift) SDK:
iOS (Obj-C) — Legacy
iOS (Swift) SDK
withDataPlaneUrl
dataPlaneUrl
withControlPlaneUrl
controlPlaneUrl
withLogLevel
Handled via LoggerAnalytics class
withDBCountThreshold
Handled via CountFlushPolicy
withSleepTimeout
Handled via FrequencyFlushPolicy
withConfigRefreshInterval
Handled internally
withTrackLifecycleEvents
trackApplicationLifecycleEvents
withRecordScreenViews
Not available. User can handle via custom plugins
withCollectDeviceId
collectDeviceId
withGzip
gzipEnabled
withAutomaticSessionTracking
Handled via SessionConfiguration.automaticSessionTracking
sessionInActivityTimeOut
Handled via SessionConfiguration.sessionTimeoutInMillis
withFactory
Not available. (This feature will be handled in future releases)
flushQueueSize
CountFlushPolicy
Removed features
The following features are removed in the iOS (Swift) SDK:
Database encryption - The dbEncryption configuration option is no longer available.
Background Mode - The enableBackgroundMode option is no longer available.
Direct context access - RSContext and getContext method are no longer available.
CocoaPods support - Only Swift Package Manager is supported.
Feature updates
This section covers the different feature updates introduced in the iOS (Swift) SDK:
To preserve the anonymousId value on a reset API call or meet a custom requirement, you can use a custom plugin to manage anonymousId for each event. Custom plugins let you modify the event payload as needed.
Flush configuration
iOS (Obj-C) — Legacy
iOS (Swift) SDK
The following configuration options are available:
You can pass custom context during the SDK initialization and via putCustomContext method.
Support for global custom context during initialization is removed. Use a custom plugin to set custom context for all events including automatically-tracked events.
You can enable or disable event delivery for specific destinations across all events while initializing the SDK or while sending events via RSOption.
Use a custom plugin to enable or disable event delivery for specific destinations across all event calls, including automatically tracked events (like lifecycle events) using the SDK.
Session tracking is tightly coupled with automatic tracking of lifecycle events. That means you cannot use session tracking if automatic lifecycle tracking is disabled.
Session tracking is decoupled with automatic tracking of lifecycle events. That means you can use the session tracking and automatic lifecycle event tracking mechanisms independently.
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.