• EnglishEspañol日本語한국어Português
  • Log inStart now

Enable Swift interaction traces

Dynamic-by-default method lookups for iOS development have been removed with Swift. This interrupts the agent's default method instrumentation. For example, interaction tracing in Swift classes are disabled by default, but you can re-enable them.

Interactions in a Swift app are captured if automatically instrumented classes and methods are used or when defining custom interactions. However, if a Swift class creates sub-classes for any of these default classes, follow these steps to capture interactions.

Enable dynamic method lookup

To re-enable dynamic method lookup on a method-by-method basis in Swift, adding the dynamic declaration modifier. For example:

class MyViewController : UIViewController {
override dynamic func viewDidLoad() {

For every function that New Relic automatically instruments, be sure to add this modifier every time you create a sub-class and override in Swift.

Enable Swift instrumentation

After adding the dynamic keyword to your method overrides, you can re-enable Swift instrumentation by calling the following method:




Call prior to [NewRelic startWithApplicationToken:...];

[NewRelic enableFeatures:NRFeatureFlag_SwiftInteractionTracing];


Call prior to NewRelic.start(withApplicationToken:)

Copyright © 2024 New Relic Inc.

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