iOS Crash分析

一 基础Crash分析

(1)当APP发生闪退,手机内部会生成一个.Crash 或者.ips 文件,里面会包含崩溃时的信息,例如下

Last Exception Backtrace:
(0x18534a364 0x184590528 0x1852e2e9c 0x185217d0c 0x101134e1c 0x100fe8a24 0x184cc6a54 0x184cc6a14 0x184cd3698 0x1852f2544 0x1852f0120 0x18520fe58 0x1870bcf84 0x18e88f67c 0x1010b2650 0x184d2c56c)

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x0000000184e5c2e8 0x184e3a000 + 140008
1   libsystem_pthread.dylib         0x0000000184f712f8 0x184f6e000 + 13048
2   libsystem_c.dylib               0x0000000184dcafbc 0x184d68000 + 405436
3   libc++abi.dylib                 0x0000000184568068 0x184566000 + 8296
4   libc++abi.dylib                 0x0000000184580568 0x184566000 + 107880
5   libc++abi.dylib                 0x000000018457fea8 0x184566000 + 106152
6   libobjc.A.dylib                 0x000000018459065c 0x184588000 + 34396
7   CoreFoundation                  0x00000001852e2e9c 0x185204000 + 913052
8   CoreFoundation                  0x0000000185217d0c 0x185204000 + 81164
9   trend                           0x0000000101134e1c 0x100e34000 + 3149340
10  trend                           0x0000000100fe8a24 0x100e34000 + 1788452
11  libdispatch.dylib               0x0000000184cc6a54 0x184cc5000 + 6740
12  libdispatch.dylib               0x0000000184cc6a14 0x184cc5000 + 6676
13  libdispatch.dylib               0x0000000184cd3698 0x184cc5000 + 59032
14  CoreFoundation                  0x00000001852f2544 0x185204000 + 976196
15  CoreFoundation                  0x00000001852f0120 0x185204000 + 966944
16  CoreFoundation                  0x000000018520fe58 0x185204000 + 48728
17  GraphicsServices                0x00000001870bcf84 0x1870b2000 + 44932
18  UIKit                           0x000000018e88f67c 0x18e81c000 + 472700
19  trend                           0x00000001010b2650 0x100e34000 + 2614864
20  libdyld.dylib                   0x0000000184d2c56c 0x184d2b000 + 5484

上面的信息我们看不懂,需要将其符号化。
(2)崩溃日志符号化
第一步:在我们上传APPStore 并且审核通过后,我们需要将.IPA文件、.xcarchive 都保存起来,方便线上崩溃日志分析。
第二步:右键 .xcarchive ,显示包内容。如下图

iOS Crash分析_第1张图片
1.png

第三步:桌面新建一个文件夹Crash,将上图中的 trend.app.dSYM 文件复制到Crash文件夹中,同时将崩溃日志 trend-2018-01-04-211936.crash也复制到文件夹中
第四步:将 symbolicatecrash工具copy到Crash文件夹,这个文件到 这个路径找

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKit.framework/Versions/A/Resources

第五步 终于可以符号化了,具体如下,根据你的路径修改一下就OK了

zxs:~ yixue$ cd /Users/yixuePXh/Desktop/crash 
zxs:crash yixue$ ./symbolicatecrash /Users/yixuePXh/Desktop/crash/trend-2018-01-04-211936.crash  /Users/yixuePXh/Desktop/crash/trend.app.dSYM  > log.crash
Error: "DEVELOPER_DIR" is not defined at ./symbolicatecrash line 69.
zxs:crash yixue$ export DEVELOPER_DIR="/Applications/XCode.app/Contents/Developer"
zxs:crash yixue$ ./symbolicatecrash /Users/yixuePXh/Desktop/crash/trend-2018-01-04-211936.crash  /Users/yixuePXh/Desktop/crash/trend.app.dSYM  > log.crash

这个时候看log.crash文件

last Exception Backtrace:
0   CoreFoundation                  0x18534a364 __exceptionPreprocess + 124
1   libobjc.A.dylib                 0x184590528 objc_exception_throw + 56
2   CoreFoundation                  0x1852e2e9c _CFThrowFormattedException + 112
3   CoreFoundation                  0x185217d0c -[__NSDictionaryM setObject:forKey:] + 932
4   trend                           0x101134e1c -[YXAPIClient actionLogWithParameter:detailedID:M6_stock_id:] (YXAPIClient.m:1075)
5   trend                           0x100fe8a24 __59-[YXProductH5ViewController yxfindDayTypeKline:index:type:]_block_invoke (YXProductH5ViewController.m:372)
6   libdispatch.dylib               0x184cc6a54 _dispatch_call_block_and_release + 24
7   libdispatch.dylib               0x184cc6a14 _dispatch_client_callout + 16
8   libdispatch.dylib               0x184cd3698 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1016
9   CoreFoundation                  0x1852f2544 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
10  CoreFoundation                  0x1852f0120 __CFRunLoopRun + 2012
11  CoreFoundation                  0x18520fe58 CFRunLoopRunSpecific + 436
12  GraphicsServices                0x1870bcf84 GSEventRunModal + 100
13  UIKit                           0x18e88f67c UIApplicationMain + 236
14  trend                           0x1010b2650 main (main.m:14)
15  libdyld.dylib                   0x184d2c56c start + 4


Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x0000000184e5c2e8 __pthread_kill + 8
1   libsystem_pthread.dylib         0x0000000184f712f8 pthread_kill$VARIANT$mp + 396
2   libsystem_c.dylib               0x0000000184dcafbc abort + 140
3   libc++abi.dylib                 0x0000000184568068 __cxa_bad_cast + 0
4   libc++abi.dylib                 0x0000000184580568 std::__terminate(void (*)()) + 44
5   libc++abi.dylib                 0x000000018457fea8 __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) + 0
6   libobjc.A.dylib                 0x000000018459065c _objc_exception_destructor(void*) + 0
7   CoreFoundation                  0x00000001852e2e9c _CFArgv + 0
8   CoreFoundation                  0x0000000185217d0c -[__NSDictionaryM setObject:forKey:] + 932
9   trend                           0x0000000101134e1c -[YXAPIClient actionLogWithParameter:detailedID:M6_stock_id:] (YXAPIClient.m:1076)
10  trend                           0x0000000100fe8a24 __59-[YXProductH5ViewController yxfindDayTypeKline:index:type:]_block_invoke (YXProductH5ViewController.m:372)
11  libdispatch.dylib               0x0000000184cc6a54 _dispatch_call_block_and_release + 24
12  libdispatch.dylib               0x0000000184cc6a14 _dispatch_client_callout + 16
13  libdispatch.dylib               0x0000000184cd3698 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1016

这个文件我们都看的懂,发现崩溃到 -[__NSDictionaryM setObject:forKey:]这个地方。

二 appstore 崩溃日志分析

第一步:打开XCode ,点击 window ->Organizer 如下图

iOS Crash分析_第2张图片
65A31FA3-E808-4946-9E34-18DF93C805E6.png

第二步,点击任意一个崩溃,例如第三行 UIKit:-(UIView(interbal) _addSubView..........
第三步,点击图右边 Open in Project,然后选择当时上传APPStore的那个tag分支(不会变)中的.xcodeproj 或者 . xcworkspace,定位到崩溃处的代码。

iOS Crash分析_第3张图片
1C34712A-84A3-474B-901A-0F908D4FA176.png

三 友盟崩溃分析,这个有一个牛人专门写了一个工具,做好的轮子我们拿来直接用就可以了,具体使用办法看github。

dSYMTools

你可能感兴趣的:(iOS Crash分析)