Get started with Performance Monitoring for iOS

Before you begin

If you haven't already, add Firebase to your iOS project.

Step 1: Add Performance Monitoring to your app

  1. Open the podfile you created for the project (or run pod init to create one), then add the following lines inside the target section:

    pod 'Firebase/Core'
    pod 'Firebase/Performance'
  2. In the directory of your podfile, run the following command to install the Performance Monitoring SDK:

    pod install
  3. Open the .xcworkspace file using Xcode.

  4. Import the Firebase module in your UIApplicationDelegate:


    import Firebase


    @import Firebase;
  5. Configure a FirebaseApp shared instance, typically in your application's application:didFinishLaunchingWithOptions: method:


    // Use Firebase library to configure APIs


    // Use Firebase library to configure APIs
    [FIRApp configure];
  6. Recompile your app.

Firebase is now monitoring automatic traces and HTTP/S network requests.

Step 2: Check the Firebase console for Performance Monitoring results

  1. Run your app in the Xcode simulator (Product > Run).

  2. Confirm that Performance Monitoring results display in the Firebase console.

    Results usually display within 12 hours.

Step 3: (Optional) Add custom traces and custom metrics

A custom trace is a report of performance data associated with some of the code in your app. To learn more about custom traces, see the Performance Monitoring overview.

You can have multiple custom traces in your app, and it's possible to have more than one custom trace running at a time. Each custom trace can have one or more metrics to count performance-related events in your app, and those metrics are associated with the traces that create them.

  1. Add the Performance Monitoring module to your header:


    import FirebasePerformance


    @import FirebasePerformance;
  2. Just before the code where you want to start a trace in your app, add the following line of code to start a trace called test trace:


    let trace = Performance.startTrace(name: "test trace")


    FIRTrace *trace = [FIRPerformance startTraceWithName:@"test trace"];
  3. To count performance-related events that occur in your app (such as cache hits or retries), add a line of code similar to the following each time that the event occurs. Use a string other than retry to name that event if you're counting a different type of event.


    trace.incrementMetric(named:"retry", by: 1)


    [trace incrementMetric:@"retry" by:1];
  4. Just after the code where you want to stop your trace, add the following line of code:




    [trace stop];

Step 4: (Optional) Add monitoring for specific network requests

Performance Monitoring collects network requests automatically. Although this includes most network requests for your app, some might not be reported.

To include custom network requests in Performance Monitoring, add the following code to your app:


guard let metric = HTTPMetric(url: "", httpMethod: .get) else { return }

guard let url = URL(string: "") else { return }
let request: URLRequest = URLRequest(url:url)
let session = URLSession(configuration: .default)
let dataTask = session.dataTask(with: request) { (urlData, response, error) in
        if let httpResponse = response as? HTTPURLResponse {
         metric.responseCode = httpResponse.statusCode


@property (nonatomic) FIRHTTPMetric *metric;

- (void)beginManualNetworkInstrumentation {
  self.metric =
      [[FIRHttpMetric alloc] initWithURL:[NSURL URLWithString:@""]

  [self.metric start];

  NSURLRequest *request =
      [NSURLRequest requestWithURL:[NSURL URLWithString:@""]];
  NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request
  [connection resume];

- (void)connection:(NSURLConnection *)connection
    didReceiveResponse:(NSURLResponse *) response {
  NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response
  self.metric.responseCode = httpResponse.statusCode;
  [self.metric stop];

The HTTP/S network requests that you specifically capture in this way appear in the Firebase console along with the network requests that Performance Monitoring captures automatically.

Step 5: Deploy your app then review results

After you've validated Performance Monitoring using the Xcode simulator and one or more test devices, you can deploy the updated version of your app to your users.

You can monitor performance data in the Firebase console.

Known issues

  • Performance Monitoring has known compatibility issues with GTMSQLite. We recommend not using Performance Monitoring with apps that use GTMSQLite.
  • Method swizzling after calling FirebaseApp.configure() might interfere with the Performance Monitoring SDK.
  • Known issues with the iOS 8.0-8.2 Simulator prevent Performance Monitoring from capturing performance events. These issues are fixed in the iOS 8.3 Simulator and later versions.
  • Connections established using NSURLSession's backgroundSessionConfiguration will exhibit longer than expected connection times. These connections are executed out-of-process and the timings reflect in-process callback events.

Next steps

Send feedback about...

Need help? Visit our support page.