Digital Measurement iOS Carthage Guide: Difference between revisions

From Engineering Client Portal

(Created page with "{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|Digital Downloads}} {{Breadcrumb|Digital Measurement iOS Artifactory Guide}} {{CurrentBreadcrumb}} Category:Digital __...")
 
 
(4 intermediate revisions by the same user not shown)
Line 4: Line 4:
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of a CocoaPods or Carthage.
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 =
= 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 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.
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 ==
== Carthage Installation ==
Line 19: Line 19:
== Repository Credentials ==
== Repository Credentials ==
The first step is to add the credentials received from Nielsen into your .netrc file.
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
<syntaxhighlight lang=Swift>
cd ~/
vi .netrc
</syntaxhighlight>
Within this file you need to add your credentials in the following format:
<syntaxhighlight lang=Javascript>
machine raw.githubusercontent.com
login <Nielsen App SDK client>
password <Auth token>
</syntaxhighlight>
<br>
<blockquote>
<blockquote>
[[Image:AlertIcon.png|left|60px|link=|class=smallIcon]] Please do not upload any file to github or bitbucket containing the credentials above.
[[Image:AlertIcon.png|left|60px|link=|class=smallIcon]] Starting on Sept 21, 2021 the Nielsen SDK has moved to a public repository. Credentials are no longer required.
This will automatically lock your access.
</blockquote>
</blockquote>
=== Credentials ===
<br>
Obtain credentials '''[[Digital Downloads| → here ←]]'''


== Carthage setup ==
== 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 AppSDK is distributed as compiled binary .framework.  
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.<br>
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.<br>
For example:
For example:
Line 48: Line 33:
</syntaxhighlight>
</syntaxhighlight>


=== Static vs Dynamic framework ===
=== Static vs Dynamic xcframework/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.<br>
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.<br>


For static framework:<br>
For static xcframework/framework:<br>
<syntaxhighlight lang=Javascript>
<syntaxhighlight lang=Javascript>
binary "https://raw.githubusercontent.com/nielsendigitalsdk/nielsenappsdk-ios-specs/master/Carthage/NielsenAppSDK/NielsenAppSDK.json"
binary "https://raw.githubusercontent.com/nielsendigitalsdk/nielsenappsdk-ios-specs/master/Carthage/NielsenAppSDK/NielsenAppSDK.json"
</syntaxhighlight>
</syntaxhighlight>
For dynamic framework:<br>
For dynamic xcframework/framework:<br>
<syntaxhighlight lang=Javascript>
<syntaxhighlight lang=Javascript>
binary "https://raw.githubusercontent.com/nielsendigitalsdk/nielsenappsdk-ios-specs-dynamic/master/Carthage/NielsenAppSDK/NielsenAppSDK.json"
binary "https://raw.githubusercontent.com/nielsendigitalsdk/nielsenappsdk-ios-specs-dynamic/master/Carthage/NielsenAppSDK/NielsenAppSDK.json"
Line 78: Line 63:


=== Nielsen AppSDK Versions ===
=== 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):
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 ====
<syntaxhighlight lang=Javascript>
8.1.0.0 -> 8.1.0
</syntaxhighlight>
==== Frameworks ====
<syntaxhighlight lang=Javascript>
<syntaxhighlight lang=Javascript>
5.1.1.29 -> 5.1.1
5.1.1.29 -> 5.1.1
Line 88: Line 78:
7.2.0.0 -> 7.2.0
7.2.0.0 -> 7.2.0
8.0.0.0 -> 8.0.0
8.0.0.0 -> 8.0.0
8.1.0.0 -> 8.1.0
</syntaxhighlight>
</syntaxhighlight>


Line 115: Line 106:


== Carthage Update ==
== Carthage Update ==
Once you prepare a Cartfile please run the following command.<br>
=== XCFrameworks ===
For iOS/tvOS/MacCatalyst:<br>
carthage update --use-xcframeworks


Once you prepare a Cartfile please run the following command.<br>
=== Frameworks ===
For iOS:<br>
For iOS:<br>
''carthage update --platform iOS --use-netrc''<br>
''carthage update --platform iOS ''<br>
For tvOS:<br>
For tvOS:<br>
''carthage update --platform tvOS --use-netrc''<br>
''carthage update --platform tvOS ''<br>


Flag --use-netrc is needed, because in the Carthage .json file we are pointing to a private Github repo as a storage.
== 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.<br><br>
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.<br>


== Framework integration for Carthage ==
== Framework integration for Carthage ==
Line 141: Line 138:
''$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/NielsenTVAppApi.framework''<br>
''$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/NielsenTVAppApi.framework''<br>


=== Additional Frameworks ===
== Additional Frameworks ==
If you integrate the static version of iOS/tvOS NielsenAppSDK framework you need to link additional system frameworks to avoid linking error:
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)
* AdSupport.framework (for IDFA frameworks only)
* CoreLocation.framework (needed for version 6.1.0 and earlier)
* CoreLocation.framework (needed for version 6.1.0 and earlier)
* libsqlite3.tbd
* libsqlite3.tbd
* SystemConfiguration.framework
* SystemConfiguration.framework
The dynamic version of iOS/tvOS NielsenAppSDK framework does not require this step.
The dynamic version of NielsenAppSDK xcframework/framework does not require this step.


== Outdated Check ==
== Outdated Check ==
Line 159: Line 156:


== SDK Versions ==
== SDK Versions ==
The following SDK versions are now available for distribution through CocoaPods and Carthage: (For 'kids' apps, please use the NoId framework (EG: NielsenNoIdAppSDK, NielsenNoIdTVOSAppSDK)  
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 ===
=== Global Builds ===
==== XCFrameworks ====
{| class="wikitable" style="width: 30%;"
|- style="background-color:#efefef;"
! App Flavor Name
|-
| NielsenAppSDK
|-
| NielsenNoAdAppSDK
|-
| NielsenNoIdAppSDK
|}
==== Frameworks ====
{| class="wikitable" style="width: 30%;"
{| class="wikitable" style="width: 30%;"
|- style="background-color:#efefef;"
|- style="background-color:#efefef;"
Line 180: Line 189:


=== Regional Builds ===
=== Regional Builds ===
(For 'kids' apps, please use the NoId framework (EG: NielsenAGFNoIdAppSDK, NielsenAGFNoIdTVOSAppSDK)  
(For 'kids' apps, please use the NoId xcframework/framework (EG: NielsenAGFNoIdAppSDK, NielsenAGFNoIdTVOSAppSDK)  
==== XCFrameworks ====
{| class="wikitable" style="width: 30%;"
|- style="background-color:#efefef;"
! App Flavor Name
|-
| NielsenAGFAppSDK
|-
| NielsenAGFNoAdAppSDK
|-
| NielsenAGFNoIdAppSDK
|}
==== Frameworks ====
{| class="wikitable" style="width: 30%;"
{| class="wikitable" style="width: 30%;"
|- style="background-color:#efefef;"
|- style="background-color:#efefef;"

Latest revision as of 20:11, 21 September 2021

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.