Tech Note TN2151 Understanding and Analyzing Application Crash Reports.

一、背景 Xcode9.2

本地怎么测试都OK,App审核传一次拒一次,说什么"crashed on launch"。App审核被拒,就给了三个crash文件和 一个链接Technical Note TN2151
Understanding and Analyzing Application Crash Reports

Tech Note TN2151 Understanding and Analyzing Application Crash Reports._第1张图片
image
Tech Note TN2151 Understanding and Analyzing Application Crash Reports._第2张图片
image
Tech Note TN2151 Understanding and Analyzing Application Crash Reports._第3张图片
image

二、符号化苹果审核给的crash文件

准备工作:

    1. 第一个是.dSYM文件(debug System) ,
    1. 第二个是苹果审核给你的crashlog.crash(需要将.txt后缀强制改为.crash后缀)
    1. 第三个是Xcode自带的 symbolicatecrash 工具

步骤:

    1. 在桌面新建一个AppCrash文件夹
    1. 右键下载crashlog-713FFD98-89E3-43EB-8834-4A93E425D100.txt,然后强制将.txt改为 .crash。eg:重新命名为crashlog.crash. 放入AppCrash文件夹中
    1. 获取 .dSYM文件, 先.Xcode --》Window--》Organizer 显示所有打包的Archives--》选着一个archives右键---》Show in Finder--->进入 . xcarchive文件 ;再 右键'显示包内容' ---》复制 .dSYM文件到步骤一中创建的文件夹中。

      Tech Note TN2151 Understanding and Analyzing Application Crash Reports._第4张图片
      image
Tech Note TN2151 Understanding and Analyzing Application Crash Reports._第5张图片
image
Tech Note TN2151 Understanding and Analyzing Application Crash Reports._第6张图片
image
  • 4 . 获取 Xcode自带symbolicatecrash 工具。
    方式一:终端命令获取
终端命令获取文件路径,有点慢,选中Finde图标---》
右键前往文件夹----》按住alt键复制一份到桌面。
 find /Applications/Xcode.app -name symbolicatecrash -type f 

Tech Note TN2151 Understanding and Analyzing Application Crash Reports._第7张图片
image
Tech Note TN2151 Understanding and Analyzing Application Crash Reports._第8张图片
image
Tech Note TN2151 Understanding and Analyzing Application Crash Reports._第9张图片
image

方式二:直接按照这个文件路径去找:应用程序--》Xcode--》显示包内容
/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash

Tech Note TN2151 Understanding and Analyzing Application Crash Reports._第10张图片
image
    1. 准备工作完成,此时 AppCrash文件夹应该有三个文件

      Tech Note TN2151 Understanding and Analyzing Application Crash Reports._第11张图片
      image
    1. 终端敲命令
    • 6-1 cd 进入文件路径

      Tech Note TN2151 Understanding and Analyzing Application Crash Reports._第12张图片
      image
    • 6-2 符号化奔溃日志。

记得中间要有空格
./symbolicatecrash crashlog.crash KISSLOCK.app.dSYM > symbol.crash

或者 
./symbolicatecrash ./crashlog.crash ./KISSLOCK.app.dSYM > symbol.crash

  • 6-3 如果上述命令出现如下报错
 Error: "DEVELOPER_DIR" is not defined at ./symbolicatecrash line 69.

就输入下面的这行代码
感谢wMellon指出问题. 很棒,指出一点:export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer",Applications前面要加/,否则设置无效,自然也就一直报错了. 已修改。

export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"

如果还报错 就把symbolicatecrash这个工具删了,重新复制一遍 symbolicatecrash 前前后后尝试了20多次,就成功了一次,现在在,有不行了。

xcrun: error: missing DEVELOPER_DIR path: Applications/Xcode.app/Contents/Developer
Error: can't find tool named 'otool' in the macosx SDK or any fallback SDKs at ./symbolicatecrash line 122.

如果不报错,就接着执行这行命令,之后可以到桌面上的这个文件夹 AppCrash查看符号化的奔溃日志 : symbol.crash

./symbolicatecrash ./crashlog.crash ./KISSLOCK.app.dSYM > symbol.crash

Tech Note TN2151 Understanding and Analyzing Application Crash Reports._第13张图片
image
  • 7 .符号化的的结果,如果运气好走到这一步

    Tech Note TN2151 Understanding and Analyzing Application Crash Reports._第14张图片
    image
Tech Note TN2151 Understanding and Analyzing Application Crash Reports._第15张图片
image

三、填坑

项目中做了国际化,还用了富文本,不同设备,不同iOS系统获取系统语言返回的返回的结果不一样,以前是zh-Hans-US 这样,现在是 zh-Hans-CN这样的。判断出问题了,富文本截取的时候越界,导致一启动就奔溃。
不同手机,不同系统得到的结果不一样的,这也就是为什么本地怎么测都是好的,一传上去就被拒绝:crashed on launch。

获取系统语言数组
  NSArray *laguageArr = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];

设备 iOS版本 结果
5s 11.2.5(15D60) "zh-Hans-CN"
6p 11.2.5(15D60) "zh-Hans-US" , "en-US"
6 10.3.2(14F89) Xcode9.2 无法真机调试

用6p升级到11.2.5系统,确实是一启动就闪退。改代码,重新上传。填了一个坑,又来了一个坑,继续被拒。

Tech Note TN2151 Understanding and Analyzing Application Crash Reports._第16张图片
image
Tech Note TN2151 Understanding and Analyzing Application Crash Reports._第17张图片
image
Tech Note TN2151 Understanding and Analyzing Application Crash Reports._第18张图片
image

本地打全局断点调试,奔溃信息和苹果反馈的奔溃日志和符号化的奔溃日志对比着看下,有些地方很相识。

Tech Note TN2151 Understanding and Analyzing Application Crash Reports._第19张图片
image

作者:RBNote
链接:https://www.jianshu.com/p/fbca51e3f561
来源:

你可能感兴趣的:(Tech Note TN2151 Understanding and Analyzing Application Crash Reports.)