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 line inside the target section:

    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:

    Swift

    import Firebase

    Objective-C

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

    Swift

    // Use Firebase library to configure APIs
    FirebaseApp.configure()

    Objective-C

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

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

Step 2: Generate performance events for initial data display

Firebase can detect that you've successfully added the SDK to your app when it receives event information (like app interactions) from your app. If you're still developing locally, interact with your app to generate events for SDK detection as well as initial data collection and processing.

  1. Continue to develop your app using a simulator or test device.

  2. Generate events by switching your app between background and foreground several times, interacting with your app by navigating across screens, and/or triggering network requests.

  3. Go to the Performance section of the Firebase console to see if Firebase has detected the SDK.

    If you don't see an "SDK detected" message, review the troubleshooting tips.

  4. Performance Monitoring processes performance event data before displaying it in the Performance dashboard. You should see your initial data display within 24 hours of seeing the SDK detection message.

    If you don't see a display of your initial data, review the troubleshooting tips.

Step 3: (Optional) View log messages for performance events

  1. Enable debug logging, as follows:

    1. In Xcode (minimum v10.3), select Product > Scheme > Edit scheme.
    2. Select Run from the left menu, then select the Arguments tab.
    3. In the Arguments Passed on Launch section, add -FIRDebugEnabled.
  2. Check your log messages for any error messages.

  3. Performance Monitoring tags its log messages with Firebase/Performance so that you can filter your log messages.

  4. Check for the following types of logs which indicate that Performance Monitoring is logging performance events:

    • Recording trace: trace-name
    • Recording network trace: url

If your app isn't logging performance events, review the troubleshooting tips.

Step 4: (Optional) Add custom monitoring for specific code

You can create custom traces to monitor performance data associated with specific code in your app.

With a custom trace, you can measure how long it takes your app to complete a specific task or set of tasks, such as loading a set of images or querying your database. The default metric for a custom trace is its duration, but you can also add custom metrics, such as cache hits and memory warnings.

In your code, you define the beginning and the end of a custom trace (and add any desired custom metrics) using the API provided by the Performance Monitoring SDK.

Visit Add custom monitoring for specific app code to learn more about these features and how to add them to your app.

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 Performance dashboard of 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