Learn about the improved features in iOS (Swift) SDK compared to the iOS (Obj-C) SDK.
4 minute read
This guide highlights the features that have been improved in the iOS (Swift) SDK compared to the iOS (Obj-C) SDK.
Configuration
The iOS (Swift) SDK uses direct initialization for a simpler and more intuitive setup.
// iOS (Swift) SDKimportRudderStackAnalytics// Initialize the RudderStack Analytics SDKletconfig=Configuration(writeKey:"<WRITE_KEY>",dataPlaneUrl:"<DATA_PLANE_URL>")letanalytics=Analytics(configuration:config)
Independent session and lifecycle management
The legacy iOS (Obj-C) SDK coupled session tracking with lifecycle events, meaning sessions could only work when lifecycle tracking was enabled.
In the new iOS (Swift) SDK, session tracking is decoupled from lifecycle events, ensuring sessions can work independently even when lifecycle tracking is turned off.
The iOS (Swift) SDK also provides a dedicated SessionConfiguration object to configure session tracking independently.
// New SDK - configure independentlyletconfiguration=Configuration(writeKey:"WRITE_KEY",dataPlaneUrl:"DATA_PLANE_URL",trackApplicationLifecycleEvents:false,// Lifecycle events offsessionConfiguration:SessionConfiguration(automaticSessionTracking:true// Sessions still work))letanalytics=Analytics(configuration:configuration)
Destination-ready callbacks with success and failure handling
The iOS (Swift) SDK provides structured result handling for destination initialization, replacing the legacy iOS (Obj-C) SDK’s simple callback approach.
Direct access to destination instances
The iOS (Swift) SDK provides direct access to destination instances via the getDestinationInstance() method, without requiring a callback to be registered immediately after SDK initialization, unlike the legacy approach.
Custom context
The legacy iOS (Obj-C) SDK provided a putCustomContext() method that accepted Map<String, Object> as the value, requiring you to always pass a nested map structure.
The iOS (Swift) SDK accepts any JSON value type, including simple strings.
The iOS (Swift) SDK lets you set externalId via RudderOption in all event types: track, screen, group, alias and identify. The legacy iOS (Obj-C) SDK only supported the identify event type.
The iOS (Swift) SDK removes redundant user identity fields from context.traits that were unnecessarily duplicated in the legacy iOS (Obj-C) SDK, thereby reducing payload size and eliminating unnecessary data inconsistency risks.
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.