Getting Started
Add Contentsquare to your app
Section titled Add Contentsquare to your appOur iOS SDK is shipped as a .xcframework
which you need to add as a dependency of your project.
How to include it
Section titled How to include itThe SDK requires Xcode 13 or later, if you are using older versions of Xcode reach out to your Contentsquare contact for more information.
Using Swift Package Manager
Section titled Using Swift Package Manager-
In Xcode, add the following links via
File > Add Packages…
:Specify Dependency Rule to “Range of Versions” with “1.20.0 < 1.27.0” for
swift-protobuf
. -
To ensure the library can start properly you will need to add
-ObjC
as a linker flag underBuild Settings
>Linking
>Other Linker Flags
.
Using Carthage
Section titled Using CarthageAdd the following lines to your Cartfile:
Then run
Drag and drop ContentsquareModule.xcframework
, SwiftProtobuf.xcframework
from the Carthage/Build folder to your targets’ General settings tab, in the Frameworks, Libraries, and Embedded Content section.
Using CocoaPods
Section titled Using CocoaPodsOur SDK can be linked dynamically or statically:
Dynamic linking
Section titled Dynamic linkingDynamic linking is the default behavior with use_frameworks!
,
Add the following line to your Podfile:
Static linking
Section titled Static linkingIf you specify static linking in your Podfile with use_frameworks! :linkage => :static
,
Follow these steps:
-
Add the following line to your Podfile:
-
To ensure the library can start properly you will need to add
-ObjC
as a linker flag underBuild Settings
>Linking
>Other Linker Flags
.
Known Issues
Section titled Known Issues-
Updating
IPHONEOS_DEPLOYMENT_TARGET
in yourpost_install
may have the following error.Workaround: Skip updating IPHONEOS_DEPLOYMENT_TARGET for SwiftProtobuf by following these steps.
-
Update your
post_install
to: -
Rerun
pod install
. -
Clean Builder Folder.
-
Rebuild.
-
Manual Integration
Section titled Manual IntegrationOur SDK can be linked dynamically or statically:
Dynamic linking
Section titled Dynamic linkingGet the manual integration framework
Section titled Get the manual integration framework- Go to the iOS SDK GitHub repository ↗.
- Find the newest version available (unless instructed otherwise by your CS contact).
- Under
Assets
you should be able to findContentsquareModuleDynamicManually.xcframework.zip
, download the file.
Include the framework
Section titled Include the framework- Unzip
ContentsquareModuleDynamicManually.xcframework.zip
and you should see a folder namedContentsquareModule
containing 2 items:
ContentsquareModule.xcframework
SwiftProtobuf.xcframework
- Copy
ContentsquareModule
to any folder in your project. - In your
target
->General
->Frameworks, Libraries and Embedded Content
, addContentsquareModule.xcframework
,SwiftProtobuf.xcframework
by clicking ”+” -> “Add Other…” -> “Add Files…“. - Clean build folder and run.
Static linking
Section titled Static linkingGet the manual integration framework
Section titled Get the manual integration framework- Go to the iOS SDK GitHub repository ↗.
- Find the newest version available (unless instructed otherwise by your CS contact).
- Under
Assets
you should be able to findContentsquareModuleStaticManually.xcframework.zip
, download the file.
Include the framework
Section titled Include the framework- Unzip
ContentsquareModuleStaticManually.xcframework.zip
and you should see a folder namedContentsquareModule
containing 3 items:ContentsquareModule.xcframework
Resources/ContentsquareBundle.bundle
SwiftProtobuf.xcframework
- Copy
ContentsquareModule
to any folder in your project. - In your
target
->General
->Frameworks, Libraries and Embedded Content
, addContentsquareModule.xcframework
,SwiftProtobuf.xcframework
by clicking ”+” -> “Add Other…” -> “Add Files…“. - Add
ContentsquareBundle.bundle
to your target, make sure it has been added to yourtarget
->Build Phases
->Copy Bundle Resources
. - To ensure the library can start properly you will need to add
-ObjC
as a linker flag underBuild Settings
>Linking
>Other Linker Flags
. - Clean build folder and run.
Start the SDK
Section titled Start the SDKAutomatic start (default)
Section titled Automatic start (default)By default, you do not need to do anything to start the SDK. Now that the SDK is a dependency of your app, it will autostart itself when your application starts.
Manual start
Section titled Manual startIf you prefer to control when the SDK starts, you can disable the autostart feature and programmatically start the SDK when needed.
The first step is to add the required key to your Info.plist
. The key is CSDisableAutostart
of type boolean. To disable the autostart, you need to set its value to true
:
-
Disable autostart using Xcode:
-
Disable autostart using a text editor:
Then just call start
in the application:didFinishLaunchingWithOptions:
of your UIApplicationDelegate
like this:
When you call the start method, the SDK automatically starts tracking users’ interactions with the app (gestures, lifecycle events and crashes).
Validate SDK integration
Section titled Validate SDK integrationWhen the SDK starts, you should see a log like this one:
If the SDK does not seem to work, it might mean that your app’s bundle id is not tied to any Contentsquare project. In that case, you will have to communicate all variants of your app’s identifier to your Contentsquare contact to be added as a project.
Now that the SDK runs in your app, you will want to implement calls to our SDK to track screenviews, track transactions, and more.
Sample App
Section titled Sample AppFor best implementation practices of our library, explore the Contentsquare for iOS sample app ↗.
Use Tealium
Section titled Use TealiumOur partner Tealium has developed a remote command module to integrate with the Contentsquare SDK. This solution leverages the convenience of iQ Tag Management to configure a native Contentsquare implementation without having to add Contentsquare-specific code to your app.
Follow instructions on Tealium’s documentation: Remote Command for Contentsquare ↗.