Install
Learn to install the Tealium SDK for iOS (Objective-C).
This section covers the previous iOS library, Objective-C. Swift is the preferred programming language for macOS, iOS, watchOS, tvOS and beyond. Swift code co-exists along side your existing Objective-C files in the same project, with full access to your Objective-C API, making it easy to adopt.
Requirements
- Xcode 7.0+
- iOS 8.1+
- Tealium iQ Mobile Profile
- Tealium Customer Data Hub account
Sample Apps
To help familiarize yourself with the Tealium library, tracking methods, and best practice implementation, explore the Tealium for iOS sample apps.
To abstract the Tealium implementation from the rest of your app, we recommend the use of a TealiumHelper
class. This gives you a single entry point from which to initialize and make tracking calls. It also allows you to update the code in your helper file, and not in every single ViewController
or header/method file.
See the TealiumIOS API for a complete listing of Tealium classes and methods for iOS.
Install
Install the Tealium SDK for iOS (Objective-C) with CocoaPods, Carthage, or manually.
CocoaPods
To install Tealium for iOS (Objective-C) for your app with CocoaPods (recommended):
-
Add the following dependency to your Podfile:
pod "TealiumIOS"
-
Save the file and run the following in your project directory:
pod install --repo-update
-
Use the created
.xcworkspace
file to continue building your app. If you do not use the.xcworkspace
file, you are not able to build the app correctly.
Carthage
To install Tealium for iOS (Objective-C) for your app with Carthage:
-
Add the following to your Cartfile:
github "tealium/tealium-ios"
-
To download and extract the frameworks, run the following command:
carthage update --platform ios --use-xcframeworks
Be sure to use the
--use-xcframeworks
flag, or the build will fail. This requires Carthage 0.38.0. -
For the required frameworks to be copied automatically at build-time, verify sure that Carthage is properly integrated into your Xcode project.
Manual
To install Tealium for iOS (Objective-C) for your app manually:
-
Add
TealiumIOS.xcframework
to your project. -
Copy framework to project in the resulting dialog box.
-
In the Target go to General > Frameworks, Libraries & Embedded Content and add
TealiumIOS.xcframework
with the “Embed & Sign” option selected.
For Swift projects go to the Build Settings > Swift Compiler > Objective-C Bridging Header option and include the file TealiumIOSBridgingHeader.h
.
Initialize
In the Application Delegate or within a helper class setup method use the following initialization code:
// set your account, profile, and environment
let tealConfig = TEALConfiguration.init(account: "ACCOUNT",
profile: "PROFILE",
environment: "ENVIRONMENT",
datasource: "DATASOURCE")
// Initialize with a unique key for this instance
guard let tealium = Tealium.newInstanceForKey("INSTANCE", configuration: tealConfig) else {
// Any additional failure response here
return
}
// import area
@import TealiumIOS;
// Set your account, profile, and environment
TEALConfiguration *tealConfig = [TEALConfiguration configurationWithAccount:@"ACCOUNT"
profile:@"PROFILE"
environment:@"ENVIRONMENT"
datasource:@"DATASOURCE"];
// Initialize with a unique key for this instance
Tealium *tealium = [Tealium newInstanceForKey:@"INSTANCE" configuration:tealConfig];
The log level is set by default from the publish settings from your iQ account. To override this setting set the logLevel
property in the TEALConfiguration instance:
// Set the log verbosity to errors only
tealConfig.logLevel = .prod
// Set the log verbosity to maximum
[tealConfig setLogLevel: TEALLogLevelDev];
The Tealium instance must be configured with the following parameters before it begins tracking:
Parameters | Type | Description | Example |
---|---|---|---|
account |
String |
Tealium account name | "companyXYZ" |
profile |
String |
Tealium profile name | "main" |
environment |
String |
Tealium environment name | ["dev" , "qa" , "prod" ] |
datasource |
String |
(Optional) data source key | "abc123" |
instance |
String |
Unique name for your instance (multiple instances are supported) | "tealium_main" |
This page was last updated: January 7, 2023