Digital Measurement iOS Swift Package Manager Guide

From Engineering Client Portal

Revision as of 04:00, 17 December 2020 by ColinBrown (talk | contribs)

Engineering Portal breadcrumbArrow.png Digital breadcrumbArrow.png Digital Downloads breadcrumbArrow.png Digital Measurement iOS Artifactory Guide breadcrumbArrow.png Digital Measurement iOS Swift Package Manager Guide

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

How to integrate Nielsen SDK in iOS/tvOS application using Swift Package Manager

Initially the Swift Package Manager (SPM) was created as a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies. However, starting from the Swift 5.3 it allows to add binary dependencies and to import proprietary, closed-source libraries into applications also.

Swift Package Manager Installation

The Swift Package Manager is available as a part of the Xcode application for MacOS. We recommend to use the Xcode version 12.x with Swift 5.3 that is the minimum required version of Swift with binary dependencies support. Apple Xcode can be downloaded and installed using Mac App Store application or from the Apple web site (https://developer.apple.com/account) in the Downloads section.

XCFramework package

Swift Package Manager only supports XCFramework type of package for binary distribution. This a new type of package supported by Apple. It has a number of benefits against the fat library packaged into a framework. First of all it allows to combine device and simulator slices into one package and it is not needed to write custom run scripts to exclude simulator slices from the embedded frameworks before deploying apps. Also XCFramework allows to combine binaries for different platforms, like iOS, tvOS, MacOS. Nielsen SDK added support for XCFramework packages and they are now available for SPM distribution.

Repository Credentials

SDK framework packages are stored on a private Github repository. To access that you need the credentials received from Nielsen.

AlertIcon.png

Please do not upload any file to github or bitbucket containing the credentials above.

This will automatically lock your access.

Credentials

Obtain credentials → here ←

SDK integration using the SPM

  1. Nielsen AppSDK can be integrated to an application in the Xcode from the menu: File -> Swift Packages -> Add Package Dependency...
  2. In the appeared popup please enter the repository address: https://github.com/NielsenDigitalSDK/nielsenappsdk-ios-dynamic-spm
  3. This a private repo, so the Xcode will immediately show a popup asking for the credentials. Please enter the credentials obtained on the previous step.
  4. On the next screen please define an SDK version for integration. There are options available for the selection. Decide whether your project accepts updates to a package dependency up to the next major version or up to the next minor version. To be more restrictive, select a specific version range or an exact version.
  5. On the next dialog please choose package product(s) you need for the application and add it(s) to the particular application build target(s).


Nielsen AppSDK Versions

iOS/tvOS AppSDK has 4 digits in the version numbers, but the SPM packages should conform to semantic versioning and contain only 3 digits in the version number. Please use only 3 first digits while specifying the exact version of the SDK:

8.0.0.0 -> 8.0.0

Nielsen AppSDK is available for distribution through the Swift Package Manager starting from 8.0.0.0 version only.

Nielsen AppSDK products

Each specific version of the Nielsen AppSD package created for the Swift Package Manager distribution has its own set of XCFramework builds - products:

Global products

(For 'kids' apps, please use the NoId framework - NielsenNoIdAppSDK)

App Flavor Name
NielsenAppSDK
NielsenNoAdAppSDK
NielsenNoIdAppSDK

Regional products

(For 'kids' apps, please use the NoId framework - NielsenAGFNoIdAppSDK)

App Flavor Name
NielsenAGFAppSDK
NielsenAGFNoAdAppSDK
NielsenAGFNoIdAppSDK

Frameworks for tvOS platform do not have their specific repositories as they are distributed as part of the same XCFramework. The following SDK versions are now available for distribution through SPM:
8.0.0

More details about SPM integration can be found in the official Apple documentation: https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app
Please note: Nielsen AppSDK is distributed through SPM as dynamic framework only.

Additional Resources for Swift Package Manager

For more information on Swift Package Manager or How to integrate the package into an application here.