Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Hướng dẫn bắt đầu nhanh này mô tả cách thiết lập Firebase Crashlytics trong ứng dụng bằng SDK Firebase Crashlytics để bạn có thể nhận được báo cáo toàn diện về sự cố trong bảng điều khiển Firebase.
Việc thiết lập Crashlytics đòi hỏi bạn phải thực hiện các thao tác trong cả bảng điều khiển Firebase và IDE (chẳng hạn như thêm tệp cấu hình Firebase và SDK Crashlytics). Để hoàn tất quá trình thiết lập, bạn cần xác định sự cố thử nghiệm để gửi báo cáo sự cố đầu tiên đến Firebase.
Trước khi bắt đầu
Nếu chưa thực hiện, hãy thêm Firebase vào dự án Apple của bạn. Nếu không có ứng dụng Apple, bạn có thể tải một ứng dụng mẫu xuống.
Nên dùng: Để tự động nhận nhật ký đường dẫn nhằm hiểu rõ các hành động của người dùng dẫn đến sự cố, lỗi không nghiêm trọng hoặc sự kiện ANR, bạn cần bật Google Analytics trong dự án Firebase của mình.
Nếu dự án Firebase hiện tại của bạn chưa bật Google Analytics, bạn có thể bật Google Analytics trong thẻ Tích hợp của settings > Cài đặt dự án trong bảng điều khiển Firebase.
Nếu bạn đang tạo một dự án Firebase mới, hãy bật Google Analytics trong quy trình tạo dự án.
Bước 1: Thêm SDK Crashlytics vào ứng dụng của bạn
Sử dụng Swift Package Manager để cài đặt và quản lý các phần phụ thuộc của Firebase.
Trong Xcode, khi dự án ứng dụng của bạn đang mở, hãy chuyển đến File > Add Packages (Tệp > Thêm gói).
Khi được nhắc, hãy thêm kho lưu trữ SDK Firebase cho các nền tảng của Apple:
Thêm cờ -ObjC vào mục Cờ trình liên kết khác trong chế độ cài đặt bản dựng của mục tiêu.
(Chỉ dành cho macOS) Trong Info.plist, hãy thêm khoá NSApplicationCrashOnExceptions và đặt khoá đó thành YES.
Khi hoàn tất, Xcode sẽ tự động bắt đầu phân giải và tải các phần phụ thuộc của bạn xuống ở chế độ nền.
Tiếp theo, hãy định cấu hình mô-đun Firebase:
Nhập mô-đun Firebase vào cấu trúc App hoặc UIApplicationDelegate:
Swift
importFirebase
Objective-C
@importFirebase;
Định cấu hình một phiên bản dùng chung FirebaseApp, thường là trong phương thức application(_:didFinishLaunchingWithOptions:) của uỷ quyền ứng dụng:
Swift
// Use the Firebase library to configure APIs.FirebaseApp.configure()
Objective-C
// Use the Firebase library to configure APIs.[FIRAppconfigure];
Bước 3: Xác định sự cố thử nghiệm để hoàn tất việc thiết lập
Để hoàn tất việc thiết lập Crashlytics và xem dữ liệu ban đầu trên trang tổng quan Crashlytics của bảng điều khiển Firebase, bạn cần xác định sự cố thử nghiệm.
Vậy là xong! Crashlytics hiện đang giám sát ứng dụng của bạn để phát hiện sự cố.
Truy cập vào Crashlytics trang tổng quan để xem và tìm hiểu tất cả báo cáo và số liệu thống kê của bạn.
Tích hợp với Google Play để bạn có thể lọc báo cáo sự cố của ứng dụng Android theo Google Play ngay trong trang tổng quan Crashlytics. Nhờ đó, bạn có thể tập trung bảng điều khiển vào các bản dựng cụ thể.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-29 UTC."],[],[],null,["\u003cbr /\u003e\n\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\niOS+ Android Android (NDK) Flutter Unity \n\n\u003cbr /\u003e\n\nThis quickstart describes how to set up Firebase Crashlytics in your app\nwith the Firebase Crashlytics SDK so that you can get comprehensive crash\nreports in the Firebase console.\n\nSetting up Crashlytics requires tasks both in the Firebase console and\nyour IDE (like adding a Firebase configuration file and the Crashlytics\nSDK). To finish setup, you'll need to force a test crash to send your first\ncrash report to Firebase.\n\nBefore you begin\n\n1. If you haven't already, [add Firebase](/docs/ios/setup) to your Apple\n project. If you don't have an Apple app, you can download a\n [sample app](/docs/samples).\n\n2. **Recommended** : To automatically get\n [breadcrumb logs](/docs/crashlytics/customize-crash-reports#get-breadcrumb-logs)\n to understand user actions leading up to a crash, non-fatal, or ANR event,\n you need to enable Google Analytics in your Firebase project.\n\n - If your existing Firebase project doesn't have Google Analytics\n enabled, you can enable Google Analytics from the\n [**Integrations** tab](https://console.firebase.google.com/project/_/settings/integrations/analytics) of your\n settings \\\u003e *Project settings*\n in the Firebase console.\n\n - If you're creating a new Firebase project, enable Google Analytics\n during the project creation workflow.\n\n \u003cbr /\u003e\n\n**Step 1** : Add the Crashlytics SDK to your app\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 Crashlytics library.\n4. To take advantage of [breadcrumb logs](/docs/crashlytics/customize-crash-reports#get-breadcrumb-logs), also add the Firebase SDK for Google Analytics to your app. Make sure that [Google Analytics is enabled](https://support.google.com/firebase/answer/9289399#linkga) in your Firebase project.\n5. Add the `-ObjC` flag to the *Other Linker Flags* section of your target's build settings.\n6. *(macOS only)* In your `Info.plist`, add the key `NSApplicationCrashOnExceptions` and set it to `YES`.\n7. When finished, Xcode will automatically begin resolving and downloading your dependencies in the background.\n\nNext, configure the Firebase module:\n\n1. Import the Firebase module in your `App` struct or `UIApplicationDelegate`:\n\n Swift \n\n ```swift\n import Firebase\n ```\n\n Objective-C \n\n ```objective-c\n @import Firebase;\n ```\n2. Configure a `FirebaseApp` shared instance, typically in your app delegate's\n `application(_:didFinishLaunchingWithOptions:)` method:\n\n Swift \n\n ```swift\n // Use the Firebase library to configure APIs.\n FirebaseApp.configure()\n ```\n\n Objective-C \n\n ```objective-c\n // Use the Firebase library to configure APIs.\n [FIRApp configure];\n ```\n\n**Step 3**: Force a test crash to finish setup\n\nTo finish setting up Crashlytics and see initial data in the\nCrashlytics dashboard of the Firebase console, you need to force a test\ncrash.\n\n\u003cbr /\u003e\n\nAnd that's it! Crashlytics is now monitoring your app for crashes.\nVisit the [Crashlytics dashboard](https://console.firebase.google.com/project/_/crashlytics) to view and investigate\nall your reports and statistics.\n\nNext steps\n\n- [Customize your crash report setup](/docs/crashlytics/customize-crash-reports) by adding opt-in reporting, logs, keys, and tracking of non-fatal errors.\n\n\u003c!-- --\u003e\n\n- [Integrate with Google Play](/docs/crashlytics/integrate-with-google-play) so that you can filter your Android app's crash reports by Google Play track directly in the Crashlytics dashboard. This allows you to better focus your dashboard on specific builds."]]