#import"ViewController.h"@implementationViewController
‐ (void)viewDidLoad{[superviewDidLoad];// Do any additional setup after loading the view, typically from a nib.UIButton*button=[UIButtonbuttonWithType:UIButtonTypeRoundedRect];button.frame=CGRectMake(20,50,100,30);[buttonsetTitle:@"Test Crash"forState:UIControlStateNormal];[buttonaddTarget:selfaction:@selector(crashButtonTapped:)forControlEvents:UIControlEventTouchUpInside];[self.viewaddSubview:button];}‐(IBAction)crashButtonTapped:(id)sender{@[][1];}@end
أنشئ تطبيقك وشغِّله في Xcode مع إيقاف مصحّح أخطاء Xcode.
انقر على play_arrowإنشاء ثم
تشغيل المخطط الحالي لإنشاء تطبيقك على جهاز اختبار أو
محاكي.
انتظِر إلى أن يتم تشغيل تطبيقك، ثم انقر على
stopإيقاف تشغيل المخطط أو
الإجراء لإغلاق النسخة الأولية من تطبيقك. كانت هذه النسخة الأولية تتضمّن برنامج تصحيح الأخطاء الذي يتعارض مع Crashlytics.
فرض حدوث عطل في الاختبار لإرسال تقرير العطل الأول لتطبيقك:
افتح تطبيقك من الشاشة الرئيسية لجهاز الاختبار أو المحاكي.
في تطبيقك، اضغط على الزر "اختبار التعطُّل" الذي أضفته باستخدام الرمز أعلاه.
بعد تعطُّل تطبيقك، شغِّله مرة أخرى من Xcode حتى يتمكّن من إرسال تقرير التعطُّل إلى Firebase.
إذا أعَدت تحميل "وحدة التحكّم" ولم يظهر لك تعطُّل الاختبار بعد خمس دقائق، حاوِل تفعيل تسجيل بيانات تصحيح الأخطاء (القسم التالي).
تفعيل ميزة تسجيل معلومات تصحيح الأخطاء في Crashlytics
إذا لم يظهر تعطل الاختبار في لوحة بيانات Crashlytics، يمكنك استخدام تسجيل تصحيح الأخطاء في Crashlytics للمساعدة في تتبُّع المشكلة.
فعِّل تسجيل معلومات تصحيح الأخطاء باتّباع الخطوات التالية:
في Xcode، انقر على المنتج (Product) > المخطّط (Scheme) > تعديل المخطّط (Edit scheme).
انقر على تشغيل (Run) من القائمة اليمنى، ثمّ انقر على علامة التبويب الوسيطات (Arguments).
في قسم المَعلمات التي تم ضبطها عند الإطلاق (Arguments Passed on Launch)، أضِف -FIRDebugEnabled.
فرض حدوث عطل اختباري يوضّح القسم الأول من هذه الصفحة كيفية إجراء ذلك.
في السجلات، ابحث عن رسالة سجل من Crashlytics تحتوي على السلسلة التالية، والتي تثبت أنّ تطبيقك يرسل الأعطال إلى Firebase.
Completed report submission
إذا لم يظهر لك هذا السجلّ أو تعذّر تسجيل عطل تجريبي في لوحة بيانات Crashlytics ضمن وحدة تحكّم Firebase بعد خمس دقائق، يُرجى التواصل مع فريق دعم Firebase وإرفاق نسخة من ناتج السجلّ لنتمكّن من مساعدتك في تحديد المشاكل وحلّها.
الخطوات التالية
تخصيص إعدادات تقرير الأعطال
من خلال إضافة ميزة إعداد التقارير عند الموافقة، والسجلات، والمفاتيح، وتتبُّع الأخطاء غير الفادحة
تاريخ التعديل الأخير: 2025-08-08 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-08-08 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Test your Crashlytics implementation\n\n\u003cbr /\u003e\n\niOS+ Android Flutter Unity \n\n\u003cbr /\u003e\n\nForce a crash to test your implementation\n-----------------------------------------\n\n| **Note:** Before forcing a crash, make sure that your app is configured to [automatically upload dSYM files](/docs/crashlytics/get-started?platform=ios#set-up-dsym-uploading).\n\n1. Add code to your app that you can use to force a test crash.\n\n You can use the following code to add a button to your app that, when\n pressed, causes a crash. The button is labeled \"Test Crash\".\n\n \u003cbr /\u003e\n\n ### SwiftUI\n\n ```swift\n Button(\"Crash\") {\n fatalError(\"Crash was triggered\")\n }\n ```\n\n ### UIKit\n\n ### Swift\n\n ```python\n import UIKit\n\n class ViewController: UIViewController {\n override func viewDidLoad() {\n super.viewDidLoad()\n\n // Do any additional setup after loading the view, typically from a nib.\n\n let button = UIButton(type: .roundedRect)\n button.frame = CGRect(x: 20, y: 50, width: 100, height: 30)\n button.setTitle(\"Test Crash\", for: [])\n button.addTarget(self, action: #selector(self.crashButtonTapped(_:)), for: .touchUpInside)\n view.addSubview(button)\n }\n\n @IBAction func crashButtonTapped(_ sender: AnyObject) {\n let numbers = [0]\n let _ = numbers[1]\n }\n }\n ```\n\n ### Objective-C\n\n ```objective-c\n #import \"ViewController.h\"\n\n @implementation ViewController\n ‐ (void)viewDidLoad {\n [super viewDidLoad];\n\n // Do any additional setup after loading the view, typically from a nib.\n\n UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect];\n button.frame = CGRectMake(20, 50, 100, 30);\n [button setTitle:@\"Test Crash\" forState:UIControlStateNormal];\n [button addTarget:self action:@selector(crashButtonTapped:)\n forControlEvents:UIControlEventTouchUpInside];\n [self.view addSubview:button];\n }\n\n ‐ (IBAction)crashButtonTapped:(id)sender {\n @[][1];\n }\n\n @end\n ```\n2. Build and run your app in Xcode with the Xcode debugger disconnected.\n\n | **The Xcode debugger prevents crash reports\n | from being sent to Crashlytics.** Complete the following steps to disconnect your test device or simulator from the Xcode debugger ***before*** forcing a crash.\n 1. Click play_arrow**Build and then\n run the current scheme** to build your app on a test device or\n simulator.\n\n 2. Wait until your app is running, then click\n stop**Stop running the scheme or\n action** to close the initial instance of your app. This initial\n instance included the debugger that interferes with Crashlytics.\n\n3. Force the test crash in order to send your app's first crash report:\n\n 1. Open your app from the home screen of your test device or simulator.\n\n 2. In your app, press the \"Test Crash\" button that you added using the code\n above.\n\n 3. After your app crashes, run it again from Xcode so that your app can\n send the crash report to Firebase.\n\n4. Go to the [Crashlytics dashboard](https://console.firebase.google.com/project/_/crashlytics) of the\n Firebase console to see your test crash.\n\nIf you've refreshed the console and you're still not seeing the test crash\nafter five minutes, try enabling debug logging (next section).\n\nEnable debug logging for Crashlytics\n------------------------------------\n\nIf you don't see your test crash in the Crashlytics dashboard, you can\nuse debug logging for Crashlytics to help track down the problem.\n\n1. Enable debug logging:\n\n 1. In Xcode, select **Product \\\u003e Scheme \\\u003e Edit scheme**.\n\n 2. Select **Run** from the left menu, then select the **Arguments** tab.\n\n 3. In the *Arguments Passed on Launch* section, add `-FIRDebugEnabled`.\n\n2. Force a test crash. The first section on this page describes how to do this.\n\n3. Within your logs, search for a log message from Crashlytics that\n contains the following string, which verifies that your app is sending\n crashes to Firebase.\n\n ```\n Completed report submission\n ```\n | After confirming that your app is sending crashes, you can optionally disable debug logging by removing the `-FIRDebugEnabled` from the arguments passed on launch.\n\nIf you don't see this log or your test crash in the Crashlytics dashboard\nof the Firebase console after five minutes, reach out to\n[Firebase Support](/support/troubleshooter/crashlytics/missing) with a copy of\nyour log output so that we can help you troubleshoot further.\n\nNext steps\n----------\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."]]