Digital Measurement iOS Carthage Guide

From Engineering Client Portal

Engineering Portal / Digital / Digital Downloads / Digital Measurement iOS Artifactory Guide / Digital Measurement iOS Carthage Guide

The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of a CocoaPods or Carthage.

How to integrate Nielsen SDK in iOS/tvOS/MacCatalyst application using Carthage

Carthage is intended to be the simplest way to add frameworks to your application. Carthage builds your dependencies and provides you with binary frameworks, but you retain full control over your project structure and setup. Please note: Carthage does not automatically modify your project files or your build settings.

Carthage Installation

The Nielsen SDK integration requires Carthage.

Install manually

Download and run the Carthage.pkg file for the latest release, then follow the on-screen instructions. If you are installing the pkg via CLI, you might need to run sudo chown -R $(whoami) /usr/local first.

Install using homebrew

Homebrew: You can use Homebrew and install the carthage tool on your system simply by running brew update and brew install carthage. (note: if you previously installed the binary version of Carthage, you should delete /Library/Frameworks/CarthageKit.framework).

The full installation guide for the Carthage is provided on the official page.

Repository Credentials

The first step is to add the credentials received from Nielsen into your .netrc file.

AlertIcon.png

Starting on Sept 21, 2021 the Nielsen SDK has moved to a public repository. Credentials are no longer required.


Carthage setup

Create a Cartfile that lists the frameworks you’d like to use in your project. A Cartfile describes your project’s dependencies to Carthage, allowing it to resolve and build them for you. The Nielsen iOS/tvOS/MacCatalys AppSDK is distributed as compiled binary .xcframework (Carthage 0.38.0+ required) and iOS/tvOS AppSDK is distributed as compiled binary .framework. The dependency on the SDK should be specified with the "binary" keyword and as an https:// URL, that returns a binary project specification in JSON format.
For example:

# Dependency on NielsenAppSDK
binary "https://raw.githubusercontent.com/nielsendigitalsdk/nielsenappsdk-ios-specs-dynamic/master/Carthage/NielsenAppSDK/NielsenAppSDK.json"

Static vs Dynamic xcframework/framework

Nielsen AppSDK is distributed as static and dynamic xcframework/framework. The corresponding path to the JSON file should be specified in the Cartfile depending on the selection you made.

For static xcframework/framework:

binary "https://raw.githubusercontent.com/nielsendigitalsdk/nielsenappsdk-ios-specs/master/Carthage/NielsenAppSDK/NielsenAppSDK.json"

For dynamic xcframework/framework:

binary "https://raw.githubusercontent.com/nielsendigitalsdk/nielsenappsdk-ios-specs-dynamic/master/Carthage/NielsenAppSDK/NielsenAppSDK.json"

SDK for Different Markets

Please change the <TARGET> in the JSON path to the proper name from the list in the end of this document.

# Static AppSDK
binary "https://raw.githubusercontent.com/nielsendigitalsdk/nielsenappsdk-ios-specs/master/Carthage/<TARGET>/NielsenAppSDK.json"
# Dynamic AppSDK
binary "https://raw.githubusercontent.com/nielsendigitalsdk/nielsenappsdk-ios-specs-dynamic/master/Carthage/<TARGET>/NielsenAppSDK.json"


For example, for NielsenAGFNoAdAppSDK target the full path is:

# Static AppSDK for NielsenAGFNoAdAppSDK
binary "https://raw.githubusercontent.com/nielsendigitalsdk/nielsenappsdk-ios-specs/master/Carthage/NielsenAGFNoAdAppSDK/NielsenAppSDK.json"
# Dynamic AppSDK for NielsenAGFNoAdAppSDK
binary "https://raw.githubusercontent.com/nielsendigitalsdk/nielsenappsdk-ios-specs-dynamic/master/Carthage/NielsenAGFNoAdAppSDK/NielsenAppSDK.json"

Nielsen AppSDK Versions

iOS/tvOS/MacCatalyst AppSDK has 4 digits in the version numbers, but the Carthage does not support 4 digit versions. Please use only 3 first digits while specifying the exact version of the SDK. Mapping from 4 digits to 3 digits version is the following (please note, older versions are not available for Carthage deployment for some targets):

XCFrameworks

8.1.0.0 -> 8.1.0

Frameworks

5.1.1.29 -> 5.1.1
6.0.0.4 -> 6.0.0
6.1.0.1 -> 6.1.0
6.2.0.0 -> 6.2.0
7.0.0.0 -> 7.0.0
7.1.0.0 -> 7.1.0
7.2.0.0 -> 7.2.0
8.0.0.0 -> 8.0.0
8.1.0.0 -> 8.1.0

Version requirement

Carthage supports several kinds of version requirements:

>= 1.0 for at least version 1.0
~> 1.0 for compatible with version 1.0
== 1.0 for exactly version 1.0

Example Cartfile

# Use the latest version
binary "https://raw.githubusercontent.com/nielsendigitalsdk/nielsenappsdk-ios-specs-dynamic/master/Carthage/NielsenAppSDK/NielsenAppSDK.json"

# Require version 7.2.0 or later
binary "https://raw.githubusercontent.com/nielsendigitalsdk/nielsenappsdk-ios-specs-dynamic/master/Carthage/NielsenAppSDK/NielsenAppSDK.json" >= 7.2.0

# Require version 7.x (7.0 or later, but less than 8.0)
binary "https://raw.githubusercontent.com/nielsendigitalsdk/nielsenappsdk-ios-specs-dynamic/master/Carthage/NielsenAppSDK/NielsenAppSDK.json" ~> 7.0

# Require exactly version 7.2.0
binary "https://raw.githubusercontent.com/nielsendigitalsdk/nielsenappsdk-ios-specs-dynamic/master/Carthage/NielsenAppSDK/NielsenAppSDK.json" == 7.2.0

Carthage Update

Once you prepare a Cartfile please run the following command.

XCFrameworks

For iOS/tvOS/MacCatalyst:
carthage update --use-xcframeworks

Frameworks

For iOS:
carthage update --platform iOS
For tvOS:
carthage update --platform tvOS

XCFramework integration for Carthage

Carthage update does not modify the application project, it just downloads the proper version into the local folder named Carthage in the same directory where the Cartfile is located.

In order to integrate the xcframework into your application open your application targets’ General settings tab. In the "Frameworks, Libraries, and Embedded Content" section, drag and drop NielsenAppApi.xcframework from the Carthage/Build folder on disk. If you are using dynamic xcframework, select "Embed & Sign", otherwise "Do Not Embed". from the pulldown menu.

Framework integration for Carthage

Carthage update does not modify the application project, it just downloads the proper version into the local folder named Carthage in the same directory where the Cartfile is located.

In order to integrate the framework into your application open your application targets’ General settings tab. In the "Frameworks, Libraries, and Embedded Content" section, drag and drop NielsenAppApi.framework (NielsenTVAppApi.framework) from the Carthage/Build folder on disk. Then, in the "Embed" section, select "Do Not Embed" from the pulldown menu.

The last step is needed for the dynamic framework only. It’s a slick workaround for an App Store submission bug where apps with frameworks that contain binary images for the iOS/tvOS simulator are automatically rejected.

  • On the application targets’ Build Phases settings tab, click the + icon and choose New Run Script Phase. Create a Run Script in which you specify your shell (ex: /bin/sh), add the following contents to the script area below the shell:

/usr/local/bin/carthage copy-frameworks

  • Add the paths to the frameworks you want to use under “Input Files".

For iOS:
$(SRCROOT)/Carthage/Build/iOS/NielsenAppApi.framework
For tvOS:
$(SRCROOT)/Carthage/Build/tvOS/NielsenTVAppApi.framework

  • Add the paths to the copied frameworks to the “Output Files”.

For iOS:
$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/NielsenAppApi.framework
For tvOS:
$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/NielsenTVAppApi.framework

Additional Frameworks

If you integrate the static version of NielsenAppSDK xcframework/framework you need to link additional system frameworks to avoid linking error:

  • AdSupport.framework (for IDFA frameworks only)
  • CoreLocation.framework (needed for version 6.1.0 and earlier)
  • libsqlite3.tbd
  • SystemConfiguration.framework

The dynamic version of NielsenAppSDK xcframework/framework does not require this step.

Outdated Check

Carthage provides an outdated check for integrated dependencies. To enable that you need to add the following line to the run script in the app /usr/local/bin/carthage outdated --xcode-warnings 2>/dev/null

The Carthage will check the latest available version of the SDK and report a warning every time the app is being built:

The following dependencies are outdated:
warning: NielsenAppSDK is out of date ("7.2.0" -> "7.2.0") (Latest: "8.0.0")

SDK Versions

The following SDK versions are now available for distribution through CocoaPods and Carthage: (For 'kids' apps, please use the NoId xcframework/framework (EG: NielsenNoIdAppSDK, NielsenNoIdTVOSAppSDK)

Global Builds

XCFrameworks

App Flavor Name
NielsenAppSDK
NielsenNoAdAppSDK
NielsenNoIdAppSDK

Frameworks

App Flavor Name
NielsenAppSDK
NielsenNoAdAppSDK
NielsenNoAdTVOSAppSDK
NielsenNoIdAppSDK
NielsenNoIdTVOSAppSDK
NielsenTVOSAppSDK

Regional Builds

(For 'kids' apps, please use the NoId xcframework/framework (EG: NielsenAGFNoIdAppSDK, NielsenAGFNoIdTVOSAppSDK)

XCFrameworks

App Flavor Name
NielsenAGFAppSDK
NielsenAGFNoAdAppSDK
NielsenAGFNoIdAppSDK

Frameworks

App Flavor Name
NielsenAGFAppSDK
NielsenAGFNoAdAppSDK
NielsenAGFNoAdTVOSAppSDK
NielsenAGFNoIdAppSDK
NielsenAGFNoIdTVOSAppSDK
NielsenAGFTVOSAppSDK

Additional Resources for Carthage

For more information on Carthage or How to set up the Cartfile in the Cartfile page.