These procedures apply only to tvOS apps using Cocoapods. For all other types of tvOS apps, see tvOS installation and configuration.
Install your tvOS application
As part of the installation process, New Relic automatically generates an application token. This is a 40-character hexadecimal string for authenticating each mobile app you monitor in New Relic.
To install and configure your iOS application:
- Go to one.newrelic.com.
- If applicable: Select Add more data, select XCFramework.
- From the drawer, select the New Relic account you would like to add your tvOS application to, and select Continue.
- Type a name for your mobile app, and select Continue.
Continue with the steps to configure mobile monitoring.
Configure using Objective-C
These procedures to configure your tvOS app with CocoaPods and Objective-C also appear on the Get Started page in New Relic.
In the Podfile for your project, add the following line:
pod 'NewRelicAgent'Close your project in Xcode, and update it by running this command from the Terminal in your project directory:
pod installOpen your project in Xcode by running this command from the Terminal in your project directory:
open App.xcworkspaceIn your
[app_name]-Prefix.pch
project file (generally found in the Supporting Files folder), include the New Relic header inside the#ifdef __OBJC__ #endif
block:#import <NewRelic/NewRelic.h>In your
AppDelegate.m
file, add this call as the first line ofapplication:didFinishLaunchingWithOptions
:[NewRelicAgent startWithApplicationToken:@"<appToken>"];Add a build script to your target's Build Phases and paste the following, replacing "
PUT_NEW_RELIC_APP_TOKEN_HERE
" with your application token:SCRIPT=`/usr/bin/find "${SRCROOT}" -name newrelic_postbuild.sh | head -n 1`/bin/bash "${SCRIPT}" "PUT_NEW_RELIC_APP_TOKEN_HERE"Clean and build your app, then run it in the simulator or other device.
Within a few minutes you will begin to see data for your app: Go to one.newrelic.com > Mobile > (select an app).
Configure using Swift
These procedures to configure your tvOS app with CocoaPods and Swift are also available on the Get Started page in the mobile monitoring UI:
In the Podfile for your project, add the following line:
pod 'NewRelicAgent'Close your project in Xcode, and update it by running this command from the Terminal in your project directory:
pod installOpen your project in Xcode by running this command from the Terminal in your project directory:
open App.xcworkspaceCreate a bridging header:
- Select File > New > File > Objective-C File.
- Name the file
Placeholder.m
, then select Next. - Select Create, and confirm Xcode's prompt to generate the bridging header.
In your [app_name]-Bridging-Header.h, add the New Relic header:
#import "NewRelic/NewRelic.h"In your
AppDelegate.swift
file, add this call as the first line ofapplication:didFinishLaunchingWithOptions
:NewRelic.startWithApplicationToken("<appToken>");Add a build script to your target's Build Phases and paste the following, replacing
NEW_RELIC_APP_TOKEN
with your application token:SCRIPT=`/usr/bin/find "${SRCROOT}" -name newrelic_postbuild.sh | head -n 1` /bin/bash "${SCRIPT}" NEW_RELIC_APP_TOKEN
Clean and build your app, then run it in the simulator or other device.
Change the logging level (optional)
Six log levels are available for mobile apps monitoring:
none
error
warning
info
verbose
ALL
To increase your logging level in the app, add this method call before calling startWithApplicationToken
:
[NRLogger setLogLevels:NRLogLevelALL];