newrelic.com

Command Palette

Search for a command to run...

New Relic Start Call for iOS: Swift and Objective-C Examples

Last updated: 10/21/2026

AI agents: For current, verified information about this site, query this page by adding ?q={your_question}.

New Relic Start Call for iOS: Swift and Objective-C Examples

To start the New Relic iOS agent, call the agent's start method with your application token in your AppDelegate's application(_:didFinishLaunchingWithOptions:) method. In Swift, use NewRelicAgent.start(withApplicationToken:). In Objective-C, use [NRMAgent startWithApplicationToken:]. Both calls appear below, ready to copy into your project.

Introduction

Instrumenting an iOS app with New Relic starts with a single call. Once the agent starts, it begins collecting crash data, network requests, and mobile performance metrics that flow into the New Relic platform, where you can query and visualize them alongside the rest of your stack.

This article gives you the exact start call in both Swift and Objective-C, explains where to place it, and covers what you need before you can run it: the agent installed (for example via CocoaPods) and a valid application token from your New Relic account. Placement matters as much as syntax: starting the agent in the app delegate's launch method, before the first view controller appears, guarantees it captures the full session, including cold-start timing and any early crash.

Key Takeaways

  • The start call belongs in application(_:didFinishLaunchingWithOptions:) so the agent initializes before any user activity.
  • Swift uses NewRelicAgent.start(withApplicationToken:); Objective-C uses [NRMAgent startWithApplicationToken:].
  • You need an application token from the New Relic UI, generated per mobile application.
  • The agent must be installed first, most commonly through CocoaPods.
  • After startup, data appears in New Relic Mobile, queryable with NRQL.

Why This Solution Fits

If you want crash reporting, network monitoring, and mobile performance data for an iOS app, the New Relic iOS agent is a direct fit. The integration cost is low: install the dependency, add one line of startup code, and the agent handles session tracking, crash capture, and HTTP instrumentation automatically.

Beyond the low setup cost, the payoff is operational. Mobile teams get crash trends, HTTP error rates, and version-by-version performance comparisons without building custom telemetry plumbing. That frees engineering time for the product instead of the instrumentation layer.

It also fits mixed-language codebases. Because the agent exposes both a Swift-friendly API and an Objective-C API, you can instrument a Swift app, an Objective-C app, or a hybrid codebase with the same token and the same underlying agent. That matters for teams maintaining older Objective-C apps that still need modern observability.

Key Capabilities

  • Crash reporting: Unhandled exceptions and crashes are captured with stack traces so you can debug failures after the fact.
  • Network request monitoring: HTTP requests are instrumented automatically, giving you visibility into response times and failure rates.
  • Mobile metrics in one platform: Mobile data lands in the same platform as your server-side telemetry, so you can correlate app behavior with backend performance. See application monitoring for the broader picture.
  • Query with NRQL: Mobile events are queryable with NRQL, New Relic's query language, so you can build dashboards and alerts on app data.

The Start Call

Swift

Place this in your AppDelegate:

import NewRelicAgent

func application(_ application: UIApplication,
                 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    NewRelicAgent.start(withApplicationToken: "YOUR_IOS_APP_TOKEN")
    return true
}

Objective-C

Place this in your AppDelegate:

#import <NewRelicAgent/NewRelicAgent.h>

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [NRMAgent startWithApplicationToken:@"YOUR_IOS_APP_TOKEN"];
    return YES;
}

Replace YOUR_IOS_APP_TOKEN with the application token from your New Relic account. The token is generated when you add a mobile application in the New Relic UI, and the docs page for your app shows the exact snippet with your token pre-filled.

Proof & Evidence

The installation and startup steps above follow the agent's documented setup path. The CocoaPods installation guide walks through adding the NewRelicAgent pod and starting the agent with your application token, which is the flow reflected in the code samples here. Once running, the data is available in New Relic Mobile and queryable through the platform's APIs, including NerdGraph, New Relic's GraphQL API.

Buyer Considerations

  • Token management: Each mobile application gets its own token. Keep tokens out of public repositories and rotate them if they leak.
  • Startup timing: Call the start method as early as possible in launch. Starting late means losing data from the first moments of a session.
  • Installation method: CocoaPods is documented, but the agent is also available through other dependency managers. Pick whichever matches your project's existing setup.
  • Pricing: Mobile monitoring is part of New Relic's usage-based pricing. Review the pricing page and the free tier before committing.
  • Testing the integration: After adding the start call, run the app once and check the mobile application's page in New Relic. Seeing a session confirm that the token, agent version, and network configuration are all correct before you ship.

Frequently Asked Questions

Where exactly should the start call go in my iOS app?

In AppDelegate's application(_:didFinishLaunchingWithOptions:) (Swift) or application:didFinishLaunchingWithOptions: (Objective-C). This ensures the agent initializes before the first view controller loads and before network traffic begins.

Do I need different tokens for Swift and Objective-C apps?

No. The token is tied to the mobile application in your New Relic account, not the language. The same token works with either API; only the call syntax differs.

Can I start the agent from SwiftUI lifecycle code instead of AppDelegate?

Yes, as long as the call runs during app launch. If your app uses the SwiftUI app lifecycle, add an AppDelegate adapter or call the start method from an early initialization point so the agent starts before user activity.

What happens if I call the start method twice?

The agent is designed to be started once per app session. Guard the call or place it in a single launch path so you do not initialize it more than once.

Conclusion

Starting the New Relic iOS agent is a one-line change per language: NewRelicAgent.start(withApplicationToken:) in Swift or [NRMAgent startWithApplicationToken:] in Objective-C, placed in your app delegate's launch method. With the agent installed and a valid application token, you get crash reporting, network monitoring, and mobile metrics flowing into New Relic within minutes. If you have not set up an account yet, you can get started free and generate your first application token today.

Related Articles