• Log in

Swift Package Manager installation

These procedures apply to iOS apps using Swift Package Manager. For other types, see iOS installation and configuration.

Install your iOS 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:

  1. Go to one.newrelic.com.
  2. If applicable: From the Mobile Apps list, select Add a new app.
  3. From the Get Started page, select iOS as the platform for mobile monitoring.
  4. Type a name for your mobile app, then select Continue.

Continue with the steps to configure New Relic for mobile monitoring.

Configure using Swift Package Manager

  1. Select File > Swift Packages > Add Package Dependency....

  2. Add the Github URL of the Package file:



    If you receive an artifact of binary target 'NewRelic' failed extraction: The operation couldn’t be completed. (TSCBasic.StringError error 1.) error when extracting the package, please close Xcode, delete the Derrived Data folder, re-open Xcode, and try again.

  3. Select the NewRelic package product, select your target, and select Finish.

  4. In your AppDelegate.swift file, add this call as the first line of applicationDidFinishLaunchWithOptions, replacing APP_TOKEN with your application token:



    To ensure proper instrumentation, you must call the agent on the first line of didFinishLaunchingWithOptions(), and run the agent on the main thread. Starting the call later, on a background thread, or asynchronously can cause unexpected or unstable behavior.

  5. Add a build script to your target's Build Phases. Ensure the new build script is the very last build script. Then paste the following, replacing APP_TOKEN with your application token:

    SCRIPT=`/usr/bin/find "${SRCROOT}" -name newrelic_postbuild.sh | head -n 1`
    if [ -z "${SCRIPT}"]; then
     SCRIPT=`/usr/bin/find "${ARTIFACT_DIR}" -name newrelic_postbuild.sh | head -n 1`
    /bin/sh "${SCRIPT}" "APP_TOKEN"
  6. 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 NewRelic.start(withApplicationToken):

Copyright © 2022 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.