ios 如何符号化崩溃日志Xcode?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25855389/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to symbolicate crash log Xcode?
提问by Nithin Pai
Xcode 5 organizer had a view which would list all the crash logs. and we could drag drop crash logs here. But since Xcode 6, I know they have moved devices out of organize and have a new window for the same. But I do not find a place where I view the crash logs which i drag-dropped in Xcode 5 after upping to Xcode 6. Anybody knows the answer ?
Xcode 5 管理器有一个视图,可以列出所有崩溃日志。我们可以在这里拖放崩溃日志。但是从 Xcode 6 开始,我知道他们已经将设备从组织中移出并有一个相同的新窗口。但是我没有找到一个地方可以查看我在升级到 Xcode 6 后拖放到 Xcode 5 中的崩溃日志。有人知道答案吗?
采纳答案by Jonny
Ok I realised that you can do this:
好的,我意识到你可以这样做:
- In
Xcode > Window > Devices
, select a connected iPhone/iPad/etc top left. - View Device Logs
- All Logs
- 在 中
Xcode > Window > Devices
,选择左上角已连接的 iPhone/iPad/etc。 - 查看设备日志
- 所有日志
You probably have a lot of logs there, and to make it easier to find your imported log later, you could just go ahead and delete all logs at this point... unless they mean money to you. Or unless you know the exact point of time the crash happened - it should be written in the file anyway... I'm lazy so I just delete all old logs (this actually took a while).
您可能在那里有很多日志,为了以后更容易找到您导入的日志,此时您可以继续删除所有日志……除非它们对您来说意味着金钱。或者除非您知道崩溃发生的确切时间点 - 无论如何都应该将其写入文件...我很懒所以我只是删除了所有旧日志(这实际上花了一段时间)。
- Just drag and drop your file into that list. It worked for me.
- 只需将您的文件拖放到该列表中即可。它对我有用。
回答by Sea Coast of Tibet
Writing this answer as much for the community as for myself.
为社区和我自己写这个答案。
If there ever are problems symbolicating a crash report, one can overcome them as follows:
如果出现象征崩溃报告的问题,可以通过以下方式克服它们:
Create a separate folder, copy
Foo.app
andFoo.app.dSYM
from the corresponding.xcarchive
into the folder. Also copy the.crash
report into the folder.Open the crash report in TextEdit or elsewhere, go to the
Binary Images:
section, and copy the first address there (e.g.0xd7000
).cd
into the folder. Now you can run the following command:xcrun atos -o Foo.app/Foo -arch arm64 -l 0xd7000 0x0033f9bb
创建一个单独的文件夹,复制
Foo.app
并Foo.app.dSYM
从对应.xcarchive
的文件夹中。还将.crash
报告复制到文件夹中。在 TextEdit 或其他地方打开崩溃报告,转到该
Binary Images:
部分,然后复制那里的第一个地址(例如0xd7000
)。cd
到文件夹中。现在您可以运行以下命令:xcrun atos -o Foo.app/Foo -arch arm64 -l 0xd7000 0x0033f9bb
This will symbolicate the symbol at address 0x0033f9bb
. Please make sure to pick the correct value for the -arch
option (can be obtaned from the first line in the Binary Images:
section, or figured out from the Hardware Model:
in the crash report and the app's supported archs).
这将象征地址处的符号0x0033f9bb
。请确保为该-arch
选项选择正确的值(可以从该Binary Images:
部分的第一行获得,或者从Hardware Model:
崩溃报告中的 和应用程序支持的拱门中获得)。
You can also copy the necessary addresses (e.g. a thread call stack) from the crash report directly into a text file (in TextEdit, hold Option and select the necessary text block, or copy and cut), to get something like this:
您还可以将崩溃报告中的必要地址(例如线程调用堆栈)直接复制到文本文件中(在 TextEdit 中,按住 Option 并选择必要的文本块,或复制和剪切),以获得如下内容:
0x000f12fb
0x002726b7
0x0026d415
0x001f933b
0x001f86d3
Now you can save this into a text file, e.g. addr.txt
, and run the following command:
现在您可以将其保存到文本文件中,例如addr.txt
,并运行以下命令:
xcrun atos -o Foo.app/Foo -arch arm64 -l 0xd7000 -f addr.txt
This will give a nice symbolication for all the addresses at once.
这将同时为所有地址提供一个很好的符号。
P.S.
聚苯乙烯
Before doing the above, it's worth checking that everything is set up correctly (as atos
will happily report something for basically any supplied address).
在执行上述操作之前,值得检查一切是否设置正确(因为atos
基本上任何提供的地址都会很高兴地报告一些内容)。
To do the checking, open the crash report, and go to the end of the call stack for Thread 0
. The first line from the end to list your app (usually the second one), e.g.:
要进行检查,请打开崩溃报告,然后转到Thread 0
. 从末尾开始的第一行列出您的应用程序(通常是第二行),例如:
34 Foo 0x0033f9bb 0xd7000 + 2525627
should be the main()
call. Symbolicating the address (0x0033f9bb
in this case) as described above should confirm that this is indeed main()
and not some random method or function.
应该是main()
电话。0x0033f9bb
如上所述符号化地址(在这种情况下)应该确认这确实是main()
而不是某种随机方法或函数。
If the address is not that of main()
, check your load address (-l
option) and arch (-arch
option).
如果地址不是main()
,请检查您的加载地址(-l
选项)和拱形(-arch
选项)。
P.P.S.
缴费灵
If the above doesn't work due to bitcode, download the dSYM for your build from iTunes Connect, extract the executable binary from the dSYM (Finder > Show Package Contents), copy it into the directory, and use it (i.e. Foo
) as the argument to atos
, instead of the Foo.app/Foo
.
如果上述由于bitcode不起作用,请从 iTunes Connect 下载您构建的 dSYM,从 dSYM(Finder > Show Package Contents)中提取可执行二进制文件,将其复制到目录中,并将其用作(即Foo
)的参数atos
,而不是Foo.app/Foo
。
回答by Mrug
You can refer this one too, I have written step by step procedure of Manual Crash Re-Symbolication.
你也可以参考这个,我已经写了手动崩溃重新符号化的分步过程。
STEP 1
第1步
Move all the above files (MyApp.app, MyApp-dSYM.dSYM and MyApp-Crash-log.crash) into a Folder with a convenient name wherever you can go using Terminal easily.
将上述所有文件(MyApp.app、MyApp-dSYM.dSYM 和 MyApp-Crash-log.crash)移动到一个具有方便名称的文件夹中,无论您去哪里都可以轻松使用终端。
For me, Desktop is the most easily reachable place ;) So, I have moved these three files into a folder MyApp at Desktop.
对我来说,桌面是最容易到达的地方 ;) 因此,我将这三个文件移动到桌面上的 MyApp 文件夹中。
STEP 2
第2步
Now its turn of Finder, Go to the path from following whichever is applicable for your XCODE version.
现在轮到 Finder,转到适用于您的 XCODE 版本的路径。
Use this command to find the symbolicatecrash
script file,find /Applications/Xcode.app -name symbolicatecrash
使用此命令查找symbolicatecrash
脚本文件,find /Applications/Xcode.app -name symbolicatecrash
Xcode 8, Xcode 9, Xcode 11 /Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash
Xcode 8、Xcode 9、Xcode 11 /Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash
Xcode 7.3
/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash
Xcode 7.3
/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash
XCode 7 /Applications/Xcode.app/Contents/SharedFrameworks/DTDeviceKitBase.framework/Versions/A/Resources/symbolicatecrash
代码 7 /Applications/Xcode.app/Contents/SharedFrameworks/DTDeviceKitBase.framework/Versions/A/Resources/symbolicatecrash
Xcode 6 /Applications/Xcode.app/Contents/SharedFrameworks/DTDeviceKitBase.framework/Versions/A/Resources
Xcode 6 /Applications/Xcode.app/Contents/SharedFrameworks/DTDeviceKitBase.framework/Versions/A/Resources
Lower then Xcode 6
Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKitBase.framework/Versions/A/Resources
低于 Xcode 6
Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKitBase.framework/Versions/A/Resources
Or
Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKit.framework/Versions/A/Resources
或者
Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKit.framework/Versions/A/Resources
STEP 3
第 3 步
Add the found symbolicatecrash script file's directory to $PATH
env variable like this: sudo vim /etc/paths.d/Xcode-symbolicatecrash
and paste the script file's directory and save the file. When opening a new terminal, you can call symbolicatecrash
at any folder as commands located in /usr/bin
.
将找到的symbolicatecrash 脚本文件的目录添加到$PATH
env 变量中,如下所示:sudo vim /etc/paths.d/Xcode-symbolicatecrash
并粘贴脚本文件的目录并保存文件。打开新终端时,您可以调用symbolicatecrash
任何文件夹作为位于/usr/bin
.
Or
或者
Copy symbolicatecrash file from this location, and paste it to the Desktop/MyApp (Wait… Don't blindly follow me, I am pasting sybolicatecrash file in folder MyApp, one that you created in step one at your favorite location, having three files.)
从这个位置复制symbolicatecrash文件,然后粘贴到桌面/MyApp(等等……不要盲目跟随我,我将sybolicatecrash文件粘贴到MyApp文件夹中,这是您在第一步中在您最喜欢的位置创建的一个,包含三个文件。 )
STEP 4
第四步
Open Terminal, and CD to the MyApp Folder.
打开终端,然后 CD 到 MyApp 文件夹。
cd Desktop/MyApp?—?Press Enter
export DEVELOPER_DIR=$(xcode-select --print-path)
?—?Press Enter
?——?按 Enter
./symbolicatecrash -v MyApp-Crash-log.crash MyApp.dSYM
?—?Press Enter
?——?按 Enter
That's it !! Symbolicated logs are on your terminal… now what are you waiting for? Now simply, Find out the Error and resolve it ;)
就是这样 !!符号日志在你的终端上......现在你还在等什么?现在简单地找出错误并解决它;)
Happy Coding !!!
快乐编码!!!
回答by Marek Manduch
For me the .crash file was enough. Without .dSYM file and .app file.
对我来说 .crash 文件就足够了。没有 .dSYM 文件和 .app 文件。
I ran these two commands on the mac where I build the archive and it worked:
我在构建存档的 mac 上运行了这两个命令,它工作正常:
export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"
/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash /yourPath/crash1.crash > /yourPath/crash1_symbolicated.crash
回答by RPM
There is an easier way using Xcode (without using command line tools and looking up addresses one at a time)
使用 Xcode 有一种更简单的方法(不使用命令行工具并一次查找一个地址)
Take any .xcarchive file. If you have one from before you can use that. If you don't have one, create one by running the Product > Archive from Xcode.
Right click on the .xcarchive file and select 'Show Package Contents'
Copy the dsym file (of the version of the app that crashed) to the dSYMs folder
Copy the .app file (of the version of the app that crashed) to the Products > Applications folder
Edit the Info.plist and edit the CFBundleShortVersionString and CFBundleVersion under the ApplicationProperties dictionary. This will help you identify the archive later
Double click the .xcarchive to import it to Xcode. It should open Organizer.
Go back to the crash log (in Devices window in Xcode)
Drag your .crash file there (if not already present)
The entire crash log should now be symbolicated. If not, then right click and select 'Re-symbolicate crash log'
获取任何 .xcarchive 文件。如果你之前有一个,你可以使用它。如果您没有,请通过从 Xcode 运行 Product > Archive 来创建一个。
右键单击 .xcarchive 文件并选择“显示包内容”
将 dsym 文件(崩溃的应用程序版本)复制到 dSYMs 文件夹
将 .app 文件(崩溃的应用程序版本)复制到 Products > Applications 文件夹
编辑Info.plist 并编辑ApplicationProperties 字典下的CFBundleShortVersionString 和CFBundleVersion。这将帮助您稍后识别存档
双击 .xcarchive 将其导入 Xcode。它应该打开管理器。
返回崩溃日志(在 Xcode 的设备窗口中)
将您的 .crash 文件拖到那里(如果尚未存在)
现在应该对整个崩溃日志进行符号化。如果没有,则右键单击并选择“重新符号化崩溃日志”
回答by Ely
Follow these steps in Xcode 10 to symbolicate a crash log from an app build on the same machine:
按照 Xcode 10 中的以下步骤来符号化来自同一台机器上构建的应用程序的崩溃日志:
- Inside Organizer, locate the archive where the app is based on.
- Click on the Download Debug Symbolsbutton. Nothing will appear in your Downloads folder, but that's OK.
- Connect the build machine to an iOS device.
- Select the device in Devices and Simulators.
- Click on the View Devices Logsbutton.
- Drag-and-drop the crash file to the left panel. The file must end with a .crashextension, otherwise the drag fails.
- Switch to the All Logstab.
- Select the added crash file.
- The file should automatically symbolicate, otherwise use the right-click context menu item Re-Symbolicate Log.
- 在Organizer 中,找到应用程序所基于的存档。
- 单击下载调试符号按钮。您的“下载”文件夹中不会出现任何内容,但没关系。
- 将构建机器连接到 iOS 设备。
- 在Devices and Simulators 中选择设备。
- 单击查看设备日志按钮。
- 将崩溃文件拖放到左侧面板。该文件必须以.crash扩展名结尾,否则拖动失败。
- 切换到所有日志选项卡。
- 选择添加的崩溃文件。
- 该文件应自动符号化,否则使用右键单击上下文菜单项Re-Symbolicate Log。
回答by Victor Bogdan
If you have the .dSYM and the .crash file in the same sub-folder, these are the steps you can take:
如果您在同一个子文件夹中有 .dSYM 和 .crash 文件,您可以采取以下步骤:
- Looking at the backtrace in the .crash file, note the name of the binary image in the second column, and the address in the third column (e.g. 0x00000001000effdc in the example below).
- Just under the backtrace, in the "Binary Images" section, note the image name, the architecture (e.g. arm64) and load address (0x1000e4000 in the example below) of the binary image (e.g. TheElements).
- Execute the following:
- 查看 .crash 文件中的回溯,注意第二列中二进制图像的名称,以及第三列中的地址(例如,下面示例中的 0x00000001000effdc)。
- 在回溯下方,在“二进制图像”部分,注意二进制图像(例如 TheElements)的图像名称、体系结构(例如 arm64)和加载地址(在下面的示例中为 0x1000e4000)。
- 执行以下操作:
$ atos -arch arm64 -o TheElements.app.dSYM/Contents/Resources/DWARF/TheElements -l 0x1000e4000 0x00000001000effdc
-[AtomicElementViewController myTransitionDidStop:finished:context:]
$ atos -arch arm64 -o TheElements.app.dSYM/Contents/Resources/DWARF/TheElements -l 0x1000e4000 0x00000001000effdc
-[AtomicElementViewController myTransitionDidStop:finished:context:]
Authoritative source: https://developer.apple.com/library/content/technotes/tn2151/_index.html#//apple_ref/doc/uid/DTS40008184-CH1-SYMBOLICATE_WITH_ATOS
权威来源:https: //developer.apple.com/library/content/technotes/tn2151/_index.html#//apple_ref/doc/uid/DTS40008184-CH1-SYMBOLICATE_WITH_ATOS
回答by Bouke
Make sure that your Xcode application name doesn't contain any spaces. This was the reason it didn't work for me. So /Applications/Xcode.app
works, while /Applications/Xcode 6.1.1.app
doesn't work.
确保您的 Xcode 应用程序名称不包含任何空格。这就是它对我不起作用的原因。所以/Applications/Xcode.app
有效,而/Applications/Xcode 6.1.1.app
不起作用。
回答by Sanchita
The easiest process to symbolicate crash logs:
符号化崩溃日志的最简单过程:
- preserve the xcarchive file from the organizer during IPA building process for future use.
- When the crash occurs, collect the crash logs from affected device. The extension should be .crash. If the crash log is in .ips format, just rename it to .crash.
- Double click the xcarchive from the stored path to make it appear in organizer(if not present already).
- open in xcode window->devices and simulators -> view device logs -> all logs -> drag and drop the .crash file.
- 在 IPA 构建过程中保留来自组织者的 xcarchive 文件以备将来使用。
- 发生崩溃时,从受影响的设备收集崩溃日志。扩展名应该是 .crash。如果崩溃日志是 .ips 格式,只需将其重命名为 .crash。
- 双击存储路径中的 xcarchive 使其出现在管理器中(如果尚未出现)。
- 在 xcode 窗口中打开 -> 设备和模拟器 -> 查看设备日志 -> 所有日志 -> 拖放 .crash 文件。
Wait for 5secs. Bang! the application calls in stack trace will be symbolicated! You may still see a lot of symbols though! those are internal library and framework calls.
等待 5 秒。砰! 堆栈跟踪中的应用程序调用将被符号化!不过,您可能仍然会看到很多符号!这些是内部库和框架调用。
This is the easiest one, tried and tested!
这是最简单的一种,久经考验!
回答by Ethan
From Apple's docs:
来自苹果的文档:
Symbolicating Crash Reports With Xcode Xcode will automatically attempt to symbolicate all crash reports that it encounters. All you need to do for symbolication is to add the crash report to the Xcode Organizer.
使用 Xcode 符号化崩溃报告 Xcode 将自动尝试符号化它遇到的所有崩溃报告。符号化所需要做的就是将崩溃报告添加到 Xcode Organizer。
- Connect an iOS device to your Mac
- Choose "Devices" from the "Window" menu
- Under the "DEVICES" section in the left column, choose a device
- Click the "View Device Logs" button under the "Device Information" section on the right hand panel
- Drag your crash report onto the left column of the presented panel
Xcode will automatically symbolicate the crash report and display the results To symbolicate a crash report, Xcode needs to be able to locate the following:
The crashing application's binary and dSYM file.
The binaries and dSYM files for all custom frameworks that the application links against. For frameworks that were built from source with the application, their dSYM files are copied into the archive alongside the application's dSYM file. For frameworks that were built by a third-party, you will need to ask the author for the dSYM file.
Symbols for the OS that the that application was running on when it crashed. These symbols contain debug information for the frameworks included in a specific OS release (e.g, iOS 9.3.3). OS symbols are architecture specific - a release of iOS for 64-bit devices won't include armv7 symbols. Xcode will automatically copy OS symbols from each device that you connect to your Mac.
- 将 iOS 设备连接到 Mac
- 从“窗口”菜单中选择“设备”
- 在左列的“设备”部分下,选择一个设备
- 单击右侧面板“设备信息”部分下的“查看设备日志”按钮
- 将您的崩溃报告拖到所显示面板的左列
Xcode 会自动符号化崩溃报告并显示结果要符号化崩溃报告,Xcode 需要能够定位以下内容:
崩溃应用程序的二进制文件和 dSYM 文件。
应用程序链接的所有自定义框架的二进制文件和 dSYM 文件。对于使用应用程序从源代码构建的框架,其 dSYM 文件将与应用程序的 dSYM 文件一起复制到存档中。对于第三方构建的框架,您需要向作者索要 dSYM 文件。
应用程序崩溃时运行的操作系统的符号。这些符号包含特定操作系统版本(例如,iOS 9.3.3)中包含的框架的调试信息。操作系统符号是特定于体系结构的 - 用于 64 位设备的 iOS 版本将不包含 armv7 符号。Xcode 将自动从您连接到 Mac 的每个设备复制操作系统符号。
If any of these are missing Xcode may not be able to symbolicate the crash report, or may only partially symbolicate the crash report.
如果缺少其中任何一个,Xcode 可能无法符号化崩溃报告,或者可能仅部分符号化崩溃报告。