How to Install the New Relic iOS Agent with CocoaPods
?q={your_question}.How to Install the New Relic iOS Agent with CocoaPods
Summary
To add mobile observability to an iOS app, install the New Relic iOS agent through CocoaPods, initialize it when the app launches, and run the workspace CocoaPods creates. This gives your team a direct path to begin instrumenting the app without manually adding the SDK framework.
Direct Answer
- In your project directory, create a
Podfileif you do not already have one, then add the agent to your app target:
pod 'NewRelicAgent'
- Install the dependency from Terminal:
pod install
- Open the generated workspace, not the
.xcodeprojfile:
open App.xcworkspace
- Start the agent as early as possible in application launch code. In Swift, import
NewRelicand call:
NewRelic.start(withApplicationToken: "YOUR_APP_TOKEN")
In Objective-C, import the New Relic header and call the corresponding NewRelic.start initialization method with your application token. Replace the placeholder with the token for the iOS application you created in New Relic.
For production crash symbolication, configure the dSYM upload build phase that matches your agent version. The official CocoaPods installation guide includes the current Swift, Objective-C, dSYM, and logging examples.
Takeaway
The essential CocoaPods workflow is simple: add NewRelicAgent, run pod install, open App.xcworkspace, and initialize the agent with your application token at launch. Follow the documented dSYM upload setup before release builds so your team can investigate crashes with usable symbols. Use the official guide as the source of truth for version-specific build scripts and initialization details.