Introduction to the Tealium Swift Library

Introduction to the Tealium Swift Library

by on ‎12-22-2017 06:37 AM - edited on ‎11-29-2018 02:44 PM by (2,364 Views)

Swift is Apple's newest programming language, designed as a replacement for Objective-C, which was originally the main programming language available across all Apple's platforms (iOS, tvOS, watchOS, macOS). Swift brings a host of improvements and is designed from the ground up to be a safer environment in which to write apps, resulting in better-performing and more robust code, and a better end-user experience. App vendors are increasingly migrating to Swift to take advantage of these new features. To simplify using Tealium with Swift, we have created a new library to make it as easy as possible to implement our products in your Swift apps.

Swift and Objective-C code can peacefully co-exist and is fully interoperable within the same app, making migration relatively easy.

In this article:

Table of Contents Placeholder

Which Library Should I Use?

The Tealium Swift library is fully compatible with apps running pure Swift, Objective-C, or any combination of the two. Since it is the newest and most up-to-date library, we strongly recommend implementing the Swift library if possible. The Objective-C library is still fully supported, but the Swift library will generally be updated faster and have the newest features. Swift additionally has the widest compatibility of all Tealium libraries, and can even support server-side Swift environments.

There are some differences between the two libraries. Check the feature comparison table below to decide which one is most suitable to your needs.

Memory Footprint and Performance

All SDKs will in some way impact the performance and/or memory of your app, which will vary between apps, It can be difficult to measure the exact footprint of a specific SDK.

Tealium has measured the Tealium Swift SDK against a baseline of a standard blank iOS Single View apps. These figures may vary for your specific implementation, so use them only as a rough indicator.

The following figures were obtained using the Xcode Allocations Instrument:

  • Compiled App Archive (.ipa file)
    • + 3MB
      Includes all available optional and mandatory/recommended modules
  • Runtime Memory Usage
    • +2 - +2.5MB
      Collect dispatcher + all other optional/recommended modules
    • +7 - +10MB
      Tag Management dispatcher (UIWebView) + Collect dispatcher + all other optional/recommended modules
  • Startup Time
    • Approximate time from initialization to completion callback firing is ≈ 0.05 seconds.

Which Swift Versions Are Supported?

  • 4.0 and above (Xcode 9.0+)

Which Operating System Versions Are Supported?

  • iOS 9.0+
  • tvOS 9.2+
  • macOS 10.11+
  • WatchOS 3.0+

Which Tealium Products Are Supported?

  • Tealium iQ Tag Management
  • Tealium EventStream
  • Tealium AudienceStream
  • Tealium DataAccess

Feature Comparison - tealium-swift vs. tealium-ios

The Swift library was built from scratch using a completely new codebase to the Objective-C library ( There are subtle differences between the two libraries in terms of the current feature set.

The following table compares the features of both libraries. If you have requests for new features, you can open an issue on our GitHub page, or contact your account manager.

Feature TealiumIOS (Objective-C) Tealium-Swift Description Notes
Instance Manager/Multiton X X Enables support for multiple Tealium instances (profiles) running in the same app. May be added to Swift in a future release. Not a widely-used feature of the Objective-C library. Most customers do not need this feature.
Auto Tracking / X Automatically tracks UIViews and Events Present in Swift, but will not be added to Objective-C
Lifecycle Tracking X X Tracks App lifecycle events. N/A 
Tag Management X X Allows use of Tealium iQ through a non-rendered web view N/A 
Tealium Collect X X Sends data to Tealium's UDH using a native HTTPS request N/A 
Offline functionality/queuing X X Automatically queues events if the device is online, and transmits when the device is online again In the iOS (Objective-C) library, queued events were persisted across app launches. This feature will be added to Swift in the next release. Current functionality is that any queued data is lost when the app is closed (swiped away) by the user.
Remote Mobile Publish Settings (MPS) X / Allows remote configuration of certain library settings Planned support in a future release. Current method of configuration is by the TealiumConfig object only, and must be set at compile time.
Volatile Data X X Stores data for the current session (until app is terminated) N/A 
Persistent Data X X Stores data between app launches N/A 
Remote Commands X X Allows triggering of specified native code blocks from Tealium iQ N/A  
Apple Search Ads Support / X Adds support for the Apple Search Ads API to collect attribution data automatically Not planning to port to Objective-C
Optimizely Experiment Tracking X / Tracks Optimizely experiment data automatically May port to Swift in future.
iOS Support X X   N/A 
watchOS Support X X   N/A 
tvOS Support X X   N/A 
macOS Support / X   N/A 
CocoaPods Support X X Support for the CocoaPods dependency manager N/A  
Carthage Support X X Support for the Carthage dependency manager N/A  
Source Code Available / X May assist with debugging N/A 
Consent Manager X X Assists with GDPR/privacy compliance N/A 
X = Present —  / = Not Available —  P = Partial Support, see Notes column

Variable Comparison - tealium-swift vs. tealium-ios

See Swift: Variables List for a list comparing the differences between Swift and Objective-C variables.