IOS crash routine tracking method and bugly Integration application detailed introduction _ios

Source: Internet
Author: User
Tags system log

IOS crash routine tracking method and bugly integration application

When the app crashes, the development phase can typically track crash information in the following ways

#1. Emulator run, view Xcode error log

#2. True machine debugging, viewing Xcode error log

#3. Real machine run, view device system log

Here are some examples of crash code Crashdemo:

-(void) viewdidload {
  [super viewdidload];
  Do no additional setup after loading the view, typically from a nib.
  [Self performselector: @selector (print) Withobject:nil afterdelay:5];
}

-(void) print {
  Nsarray *array = @[];
  NSLog (@ "%@", array[1]);


Demo#1. Emulator run, view Xcode error log

The program will crash immediately after execution, open the Xcode system log to see the following error message

2016-10-29 12:13:29.015 crashdemo[37842:7436441] * * * terminating app due to uncaught exception ' nsrangeexception ', Reason : ' * * *-[__nsarray0 Objectatindex:]: Index 1 beyond bounds for empty nsarray ' * * * A-throw ' * * * the call stack: (0 corefound ation 0x00b7ba84 __exceptionpreprocess + 180 1 LIBOBJC. A.dylib 0x00642e02 Objc_exception_throw + 2 corefoundation 0x00b22390 __cfarraygettypeid_block_i Nvoke + 0 3 corefoundation 0x00ac07f8-[nsarray objectatindexedsubscript:] + 4 Crashdemo 0 X000877b7-[viewcontroller Print] + 5 Foundation 0x00250d71 __nsfiredelayedperform + 442 6 Corefounda tion 0x00acd576 __cfrunloop_is_calling_out_to_a_timer_callback_function__ + 7 corefoundation 0x0           0ACCF72 __cfrunloopdotimer + 1250 8 corefoundation 0x00a8b25a __cfrunlooprun + 2202 9 corefoundation 0x00a8a706 cfrunlooprunspecific + 470 corefoundation 0x00a8a51b Cfrunloopruninmode + 123 graphicsservices 0x041e4664 Gseventrunmodal + graphicsservices 0X041E44A1 Gseventrun + uikit 0x00f0c1eb uiapplicationmain + 160 Crashdemo 0 X00087bba main + 138 libdyld.dylib 0x03189a21 start + 1) libc++abi.dylib:terminating with uncaught excep 
 tion of type nsexception (LLDB)

Through the Xcode log you can see that array access is out of bounds, and that a way out of bounds is named print

For this demo we are of course very clear that the list of array[1] is out of bounds, but for a complete program, how do you see where it is going to go out of bounds?

This time we can take advantage of the Xcode show the breakpoint navigator function, dot plus select Add Exception breakpoint

This time we are executing the program, Xcode execution will automatically stop at the code snippet that is going to happen crash

Demo#2. True machine debugging, viewing Xcode error log
If you add Exeception point, the program automatically stops to the line that prints array[1]. If you do not add the program will crash, Xcode will receive the following error log

2016-10-29 12:15:53.561 crashdemo[1062:316582] * * * terminating app due to uncaught exception ' nsrangeexception ', Reason: '  -[__nsarray0 Objectatindex:]: Index 1 beyond bounds for empty nsarray '
* * * I-throw call stack:
(0x211b398b 0x2094ee17 0x211433e7 0xc5a3b 0x219d1ad5 0x211765ff 0x21176231 0x2117407d 0x210c32e9 0x210c30d5 0x226b3ac9 0x257880b9 0xc 5c99 0x20d6b873)
libc++abi.dylib:terminating with uncaught exception of type NSException
(LLDB) 

Through the error message we can only see that there is an array access out of bounds, if added exeception breakpoint will automatically stop at the line of code where the error occurred.

Demo#3. Real machine run, view device system log

Xcode stop running this crashdemo, select Xcode window-devices, select Mobile-View device logs

Then run Crashdemo on the phone and device logs to see the latest log in the Crashdemo crash log.

Incident identifier:9a4c52f0-b0d7-42c9-a7cb-d4d3321d00d5 crashreporter Key: 90f4d3621773443794fa73f506fd6bdef49fc269 hardware model:iphone4,1 Process:crashdemo [1074] Path:/private /var/containers/bundle/application/1307034e-9c2b-451f-acd9-04c97dec047b/crashdemo.app/crashdemo Identifier:pega . Crashdemo Version:1 (1.0) Code type:arm (Native) Parent process:launchd [1] date/time:2016-10-29 12 : 21:49.49 +0800 Launch time:2016-10-29 12:21:43.43 +0800 OS version:ios 9.3.1 (13E238) version:104 Ex Ception Type:exc_crash (SIGABRT) Exception codes:0x0000000000000000, 0x0000000000000000 Exception note:exc_corpse_ NOTIFY triggered by thread:0 filtered Syslog:none found last Exception backtrace:0 corefoundation 0x211b398 6 __exceptionpreprocess + 122 1 LIBOBJC.  A.dylib 0x2094ee12 Objc_exception_throw + 2 corefoundation 0x211433e2-[__nsarray0 Objectatindex:] + 3 Crashdemo 0x000e6a36 0xe0000 + 27190 4 Foundation 0x219d1ad0 __nsfiredelayedperform + 464 5 corefoundation 0x211765f 

 A

These are easy to implement in the development phase, but when the app released after the user happened crash? The average user can only feedback what happens when crash

Then we're going to try and see if we can, but it's not very efficient and it's generally hard to replicate to the user's crash.

Bugly the emergence of the solution to this problem

The Bugly SDK automatically sends error messages to the server when the program crashes to facilitate developers to view the analysis

So how do you use bugly?

First to https://bugly.qq.com/v2/registered account, and registered app Download SDK package

Drag the bugly.framework to the project and remember to check the copy if needed.

And then add libz.tbd/libstdc++.tbd/security.framework/systemconfiguration.framework to the project.

Register in DELEGATE.M

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions { 
    [bugly startwithappid:@ "Replace here with your AppID"]; 
    Return YES 
 }

So when the program crashes, crash information is automatically sent to the server login your bugly account will be able to find out.

Thank you for reading, I hope to help you, thank you for your support for this site!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.