我们经常会用到一些统计App错误的工具,拿友盟为例,当我们拿到这些错误详情该如何定位到项目中的代码呢?不多说直接先上一段错误详情:
*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0](null)
((0 CoreFoundation
0x00000001816dc1d8+ 1481 libobjc.A.dylib
0x000000018011455c objc_exception_throw + 562 CoreFoundation
0x00000001815b84ac+ 03 MyAPP
0x1001c5ff8 MyAPP + 18595764 MyAPP
0x10005bb84 MyAPP + 3756845 UIKit
0x00000001878675c4+ 7166 UIKit
0x00000001878677f4+ 807 UIKit
0x0000000187854d9c+ 23048 UIKit
0x000000018786c858+ 1169 UIKit
0x0000000187608d04+ 17610 UIKit
0x0000000187521738+ 119611 QuartzCore
0x00000001849ea40c+ 14812 QuartzCore
0x00000001849df0e8+ 29213 QuartzCore
0x00000001849defa8+ 3214 QuartzCore
0x000000018495bc64+ 25215 QuartzCore
0x00000001849830d0+ 51216 QuartzCore
0x0000000184983af0+ 12017 CoreFoundation
0x00000001816897dc+ 3218 CoreFoundation
0x000000018168740c+ 37219 CoreFoundation
0x000000018168789c+ 102420 CoreFoundation
0x00000001815b6048 CFRunLoopRunSpecific + 44421 GraphicsServices 0x0000000183039198 GSEventRunModal + 18022 UIKit
0x000000018758f818+ 68423 UIKit
0x000000018758a550 UIApplicationMain + 20824 MyAPP
0x10015b3d4 MyAPP + 142229225 libdyld.dylib
0x00000001805985b8+ 4
)
dSYM UUID: XXXXXXXX-E01E-XXXX-XXXX-C328E621XXC22
CPU Type: arm64
Slide Address: 0x0000000100000000
Binary Image: MyAPP
Base Address: 0x0000000100044000
这里我们如何知道是哪里的数组越界了,错误里面并没有给出所涉及的页面,那我们如何找出出现错误的代
码?
1.先通过Xcode打开organizer,找到你打包的那个文件,show in Finder
2.会看到.xcarchive文件,右击显示包内容,找到dSYMs文件夹,点击进入有个MyApp.app.dSYM
3.右击MyApp.app.dSYM,显示包内容,进入Contents/Resources/DWARF,有个MyAPP
4.通过终端进入Contents/Resources/DWARf,命令行键入atos -o MyApp 0x000000(出现错误的地址)即可。
网友评论