Schritt 1: Performance Monitoring in die App einfügen
Nachdem Sie das Performance Monitoring SDK hinzugefügt haben, beginnt Firebase automatisch mit der Erfassung von Daten für das Rendern von Bildschirmen in Ihrer App, von Daten zum Lebenszyklus Ihrer App (z. B. App-Startzeit) und von Daten für HTTP(S)-Netzwerkanfragen.
Verwenden Sie Swift Package Manager, um Firebase-Abhängigkeiten zu installieren und zu verwalten.
Öffnen Sie Ihr App-Projekt und gehen Sie in Xcode zu File > Add Packages (Datei > Pakete hinzufügen).
Fügen Sie bei entsprechender Aufforderung das Firebase Apple Platforms SDK-Repository hinzu:
https://github.com/firebase/firebase-ios-sdk.git
Wählen Sie die Performance Monitoring-Bibliothek aus.
Fügen Sie das Flag -ObjC dem Abschnitt Other Linker Flags (Weitere Linker-Flags) der Build-Einstellungen Ihres Ziels hinzu.
Wenn Sie fertig, beginnt Xcode automatisch, Ihre Abhängigkeiten im Hintergrund aufzulösen und herunterzuladen.
Konfigurieren Sie als Nächstes das Firebase-Modul:
Importieren Sie das FirebaseCore-Modul in Ihre UIApplicationDelegate sowie alle anderen Firebase-Module, die von Ihrem App-Delegaten verwendet werden.
So verwenden Sie beispielsweise Cloud Firestore und Authentication:
Konfigurieren Sie eine freigegebene FirebaseApp-Instanz in der Methode application(_:didFinishLaunchingWithOptions:) des App-Delegaten:
SwiftUI
// Use Firebase library to configure APIsFirebaseApp.configure()
Swift
// Use Firebase library to configure APIsFirebaseApp.configure()
Objective-C
// Use Firebase library to configure APIs[FIRAppconfigure];
Wenn Sie SwiftUI verwenden, müssen Sie ein Anwendungs-Delegate erstellen und es über UIApplicationDelegateAdaptor oder NSApplicationDelegateAdaptor an Ihre App-Struktur anhängen. Außerdem müssen Sie das Swizzling von App-Delegaten deaktivieren. Weitere Informationen finden Sie in der SwiftUI-Anleitung.
SwiftUI
@mainstructYourApp:App{// register app delegate for Firebase setup@UIApplicationDelegateAdaptor(AppDelegate.self)vardelegatevarbody:someScene{WindowGroup{NavigationView{ContentView()}}}}
Kompilieren Sie die App neu.
Schritt 2: Leistungsereignisse für die erste Datenanzeige generieren
Firebase beginnt mit der Verarbeitung der Ereignisse, wenn Sie das SDK erfolgreich in Ihre App eingebunden haben. Wenn Sie noch lokal entwickeln, interagieren Sie mit Ihrer App, um Ereignisse für die erste Datenerhebung und ‑verarbeitung zu generieren.
Entwickeln Sie Ihre App mit einem Simulator oder Testgerät weiter.
Generieren Sie Ereignisse, indem Sie Ihre App mehrmals zwischen Hintergrund und Vordergrund wechseln, mit Ihrer App interagieren, indem Sie auf verschiedenen Bildschirmen navigieren, und/oder Netzwerkanfragen auslösen.
Rufen Sie das Dashboard zur Leistungsüberwachung der Firebase-Konsole auf. Die ersten Daten sollten innerhalb weniger Minuten angezeigt werden.
Klicken Sie auf die URL, um Ihre Daten in der Firebase Console aufzurufen. Es kann einige Momente dauern, bis die Daten im Dashboard aktualisiert werden.
Schritt 4: (Optional) Benutzerdefinierte Überwachung für bestimmten Code hinzufügen
Wenn Sie Leistungsdaten für bestimmten Code in Ihrer App erfassen möchten, können Sie benutzerdefinierte Code-Traces instrumentieren.
Mit einem benutzerdefinierten Code-Trace können Sie messen, wie lange Ihre App für die Ausführung einer bestimmten Aufgabe oder einer Reihe von Aufgaben benötigt, z. B. zum Laden einer Reihe von Bildern oder zum Abfragen Ihrer Datenbank. Der Standardmesswert für einen benutzerdefinierten Code-Trace ist seine Dauer. Sie können aber auch benutzerdefinierte Messwerte wie Cache-Treffer und Speicherwarnungen hinzufügen.
In Ihrem Code definieren Sie den Anfang und das Ende eines benutzerdefinierten Code-Traces und fügen mithilfe der vom Performance Monitoring SDK bereitgestellten API alle gewünschten benutzerdefinierten Messwerte hinzu.
Weitere Informationen zu diesen Funktionen und dazu, wie Sie sie in Ihre App einfügen, finden Sie hier.
Schritt 5: App bereitstellen und Ergebnisse ansehen
Nachdem Sie Performance Monitoring mit dem Xcode-Simulator und einem oder mehreren Testgeräten validiert haben, können Sie die aktualisierte Version Ihrer App für Ihre Nutzer bereitstellen.
Performance Monitoring hat bekannte Kompatibilitätsprobleme mit GTMSQLite. Wir empfehlen, Performance Monitoring nicht mit Apps zu verwenden, die GTMSQLite nutzen.
Method Swizzling nach dem Aufrufen von FirebaseApp.configure() kann die Funktion des Performance Monitoring SDK beeinträchtigen.
Bekannte Probleme mit dem iOS 8.0–8.2-Simulator verhindern, dass Performance Monitoring Leistungsereignisse erfasst. Diese Probleme wurden im iOS 8.3-Simulator und in späteren Versionen behoben.
Verbindungen, die mit backgroundSessionConfiguration von NSURLSession hergestellt werden, weisen längere Verbindungszeiten als erwartet auf. Diese Verbindungen werden außerhalb des Prozesses ausgeführt und die Zeitangaben spiegeln In-Process-Callback-Ereignisse wider.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-05 (UTC)."],[],[],null,["\u003cbr /\u003e\n\nBefore you begin\n\nIf you haven't already,\n[add Firebase to your Apple project](/docs/ios/setup).\n| **Note:** Firebase supports both CocoaPods and Swift Package Manager. If you choose to install Firebase using [Swift Package Manager](/docs/ios/swift-package-manager), you can skip CocoaPods-related steps, like modifying Podfiles and running the `pod` command.\n\n**Step 1** : Add Performance Monitoring to your app\n\nAfter you've added the Performance Monitoring SDK, Firebase automatically starts collecting\ndata for your app's [screen rendering](/docs/perf-mon/screen-traces), data\nrelated to your app's lifecycle (like\n[app start time](/docs/perf-mon/app-start-foreground-background-traces)), and\ndata for [HTTP/S network requests](/docs/perf-mon/network-traces?platform=ios).\n\nUse Swift Package Manager to install and manage Firebase dependencies.\n| Visit [our installation guide](/docs/ios/installation-methods) to learn about the different ways you can add Firebase SDKs to your Apple project, including importing frameworks directly and using CocoaPods.\n\n1. In Xcode, with your app project open, navigate to **File \\\u003e Add Packages**.\n2. When prompted, add the Firebase Apple platforms SDK repository: \n\n```text\n https://github.com/firebase/firebase-ios-sdk.git\n```\n| **Note:** New projects should use the default (latest) SDK version, but you can choose an older version if needed.\n3. Choose the Performance Monitoring library.\n4. Add the `-ObjC` flag to the *Other Linker Flags* section of your target's build settings.\n5. When finished, Xcode will automatically begin resolving and downloading your dependencies in the background.\n\nNext, configure the Firebase module:\n\n1. Import the `FirebaseCore` module in your `UIApplicationDelegate`, as well as any other [Firebase modules](/docs/ios/setup#available-pods) your app delegate uses. For example, to use Cloud Firestore and Authentication: \n\n SwiftUI \n\n ```swift\n import SwiftUI\n import FirebaseCore\n import FirebaseFirestore\n import FirebaseAuth\n // ...\n \n ```\n\n Swift \n\n ```swift\n import FirebaseCore\n import FirebaseFirestore\n import FirebaseAuth\n // ...\n \n ```\n\n Objective-C \n\n ```objective-c\n @import FirebaseCore;\n @import FirebaseFirestore;\n @import FirebaseAuth;\n // ...\n \n ```\n2. Configure a [`FirebaseApp`](/docs/reference/swift/firebasecore/api/reference/Classes/FirebaseApp) shared instance in your app delegate's `application(_:didFinishLaunchingWithOptions:)` method: \n\n SwiftUI \n\n ```swift\n // Use Firebase library to configure APIs\n FirebaseApp.configure()\n ```\n\n Swift \n\n ```swift\n // Use Firebase library to configure APIs\n FirebaseApp.configure()\n ```\n\n Objective-C \n\n ```objective-c\n // Use Firebase library to configure APIs\n [FIRApp configure];\n ```\n3. If you're using SwiftUI, you must create an application delegate and attach it to your `App` struct via `UIApplicationDelegateAdaptor` or `NSApplicationDelegateAdaptor`. You must also disable app delegate swizzling. For more information, see the [SwiftUI instructions](/docs/ios/learn-more#swiftui). \n\n SwiftUI \n\n ```swift\n @main\n struct YourApp: App {\n // register app delegate for Firebase setup\n @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate\n\n var body: some Scene {\n WindowGroup {\n NavigationView {\n ContentView()\n }\n }\n }\n }\n \n ```\n4. Recompile your app.\n\n| **Note:** When you add Performance Monitoring to your app, the Remote Config SDK is included as a dependency. If you already use Remote Config, you won't see any difference. However, if you're new to Remote Config, explore the [Remote Config documentation](/docs/remote-config/ios) to learn more about the various features you'll be able to access in your app.\n\n**Step 2**: Generate performance events for initial data display\n\nFirebase starts processing the events when you successfully add the SDK to your\napp. If you're still developing locally, interact with your app to generate\nevents for initial data collection and processing.\n| **Note:** The Performance Monitoring SDK batches events locally then sends them to Firebase periodically (every 30 seconds) or when the app comes back to foreground. So, there's a delay between an app interaction and when Firebase receives the event information from your app.\n\n1. Continue to develop your app using a simulator or test device.\n\n2. Generate events by switching your app between background and foreground\n several times, interacting with your app by navigating across screens,\n and/or triggering network requests.\n\n3. Go to the [*Performance* dashboard](//console.firebase.google.com/project/_/performance)\n of the Firebase console. You should see your initial data display within\n a few minutes.\n\n If you don't see a display of your initial data, review the [troubleshooting\n tips](/docs/perf-mon/troubleshooting?platform=ios#sdk-detected-no-data).\n\n**Step 3** : *(Optional)* View log messages for performance events\n\n1. Enable debug logging, as follows:\n\n 1. In Xcode (minimum v16.2), select **Product** \\\u003e **Scheme** \\\u003e **Edit scheme**.\n 2. Select **Run** from the left menu, then select the **Arguments** tab.\n 3. In the *Arguments Passed on Launch* section, add `-FIRDebugEnabled`.\n2. Check your log messages for any error messages.\n\n3. Performance Monitoring tags its log messages with `Firebase/Performance` so that you\n can filter your log messages.\n\n4. Check for the following types of logs which indicate that Performance Monitoring is\n logging performance events:\n\n - `Logging trace metric: `\u003cvar translate=\"no\"\u003eTRACE_NAME\u003c/var\u003e`, `\u003cvar translate=\"no\"\u003eFIREBASE_PERFORMANCE_CONSOLE_URL\u003c/var\u003e\n - `Logging network request trace: `\u003cvar translate=\"no\"\u003eURL\u003c/var\u003e\n5. Click on the URL to view your data in the Firebase console. It may take a few\n moments for the data to update in the dashboard.\n\nIf your app isn't logging performance events, review the [troubleshooting\ntips](/docs/perf-mon/troubleshooting?platform=ios#app-not-logging-events).\n\n**Step 4** : *(Optional)* Add custom monitoring for specific code\n\nTo monitor performance data associated with specific code in your app, you can\ninstrument [**custom code traces**](/docs/perf-mon/custom-code-traces).\n\nWith a custom code trace, you can measure how long it takes your app to complete\na specific task or set of tasks, such as loading a set of images or querying\nyour database. The default metric for a custom code trace is its duration, but\nyou can also add custom metrics, such as cache hits and memory warnings.\n\nIn your code, you define the beginning and the end of a custom code trace (and\nadd any desired custom metrics) using the API provided by the Performance Monitoring SDK.\n\n\nVisit [Add monitoring for specific code](/docs/perf-mon/custom-code-traces)\nto learn more about these features and how to add them to your app.\n\n**Step 5**: Deploy your app then review results\n\nAfter you've validated Performance Monitoring using the Xcode simulator and one or more\ntest devices, you can deploy the updated version of your app to your users.\n\nYou can monitor performance data in the\n[*Performance* dashboard](//console.firebase.google.com/project/_/performance)\nof the Firebase console.\n\nKnown issues\n\n- Performance Monitoring has known compatibility issues with GTMSQLite. We recommend not using Performance Monitoring with apps that use GTMSQLite.\n- Method swizzling after calling `FirebaseApp.configure()` might interfere with the Performance Monitoring SDK.\n- 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.\n- 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.\n\nNext steps\n\n- Review and run the\n [Performance Monitoring iOS code sample on GitHub](//github.com/firebase/quickstart-ios/tree/master/performance).\n\n- Learn more about data automatically collected by Performance Monitoring:\n\n - Data related to your app's lifecycle, like [app start time](/docs/perf-mon/app-start-foreground-background-traces?platform=ios)\n - Data for [screen rendering](/docs/perf-mon/screen-traces?platform=ios) in your app\n - Data for [HTTP/S network requests](/docs/perf-mon/network-traces?platform=ios) issued by your app\n- [View, track, and filter](/docs/perf-mon/console?platform=ios) your\n performance data in the Firebase console.\n\n- Add monitoring for specific tasks or workflows in your app by\n [instrumenting custom code traces](/docs/perf-mon/custom-code-traces?platform=ios).\n\n- [Use attributes to filter performance data](/docs/perf-mon/attributes?platform=ios)."]]