---
title: Enable Swift interaction traces
source: https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-ios/configuration/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](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/mobile-sdk-api-guide/#method-list-ios) 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 [#enable-dynamic]

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

```swift
class MyViewController : UIViewController {
    override dynamic func viewDidLoad() {
        super.viewDidLoad()
        ...
    }
}
```

For every function that New Relic [automatically instruments](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/mobile-sdk-api-guide/#method-list-ios), be sure to add this modifier every time you create a sub-class and override in Swift.

## Enable Swift instrumentation [#swift-instrumentation]

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

| **Language** | **Procedure**                                                                                                                                             |
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Objective-C  | Call prior to `[NewRelic startWithApplicationToken:...];` ````objectivec [NewRelic enableFeatures:NRFeatureFlag_SwiftInteractionTracing]; ```  ````       |
| Swift        | Call prior to `NewRelic.start(withApplicationToken:)` ````swift NewRelic.enableFeatures(NRMAFeatureFlags.NRFeatureFlag_SwiftInteractionTracing) ```  ```` |
