Digital Measurement iOS Carthage Guide
From Engineering Client Portal
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 application using Carthage
Carthage is intended to be the simplest way to add frameworks to your Cocoa 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.
The Nielsen SDK integration requires Carthage.
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.
The first step is to add the credentials received from Nielsen into your .netrc file. Navigate to your home folder and create a file called .netrc
cd ~/ vi .netrc
Within this file you need to add your credentials in the following format:
machine raw.githubusercontent.com login <Nielsen App SDK client> password <Auth token>
Please do not upload any file to github or bitbucket containing the credentials above.
This will automatically lock your access.
Obtain credentials → here ←
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 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.
# Dependency on NielsenAppSDK binary "https://raw.githubusercontent.com/nielsendigitalsdk/nielsenappsdk-ios-specs-dynamic/master/Carthage/NielsenAppSDK/NielsenAppSDK.json"
Static vs Dynamic framework
Nielsen AppSDK is distributed as static and dynamic framework. The corresponding path to the JSON file should be specified in the Cartfile depending on the selection you made.
For static framework:
For dynamic framework:
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 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):
188.8.131.52 -> 5.1.1 184.108.40.206 -> 6.0.0 220.127.116.11 -> 6.1.0 18.104.22.168 -> 6.2.0 22.214.171.124 -> 7.0.0 126.96.36.199 -> 7.1.0 188.8.131.52 -> 7.2.0 184.108.40.206 -> 8.0.0
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”
# 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
Once you prepare a Cartfile please run the following command.
carthage update --platform iOS --use-netrc
carthage update --platform tvOS --use-netrc
Flag --use-netrc is needed, because in the Carthage .json file we are pointing to a private Github repo as a storage.
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:
- Add the paths to the frameworks you want to use under “Input Files".
- Add the paths to the copied frameworks to the “Output Files”.
If you integrate the static version of iOS/tvOS NielsenAppSDK 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)
The dynamic version of iOS/tvOS NielsenAppSDK framework does not require this step.
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")
The following SDK versions are now available for distribution through CocoaPods and Carthage: (For 'kids' apps, please use the NoId framework (EG: NielsenNoIdAppSDK, NielsenNoIdTVOSAppSDK)
|App Flavor Name|
(For 'kids' apps, please use the NoId framework (EG: NielsenAGFNoIdAppSDK, NielsenAGFNoIdTVOSAppSDK)
|App Flavor Name|