When you run the Build and Archive command, Xcode 3.2.2 or later fetches your application binary and its associated .dSYM
file and saves them in your home folder.
The .dSYM
, which contains symbol information that are useful for debugging and symbolizing crash reports, is created by setting the "Debug Information Format" build setting to DWARF with dSYM File
and enabling the "Generate Debug Symbols" build setting in Xcode.
XCode编译App, dSYM
http://www.anoshkin.net/blog/2008/09/09/iphone-crash-logs/
在XCODE编译项目之后,会在app旁看见一个同名的dSYM文件.
他是一个编译的中转文件,简单说就是debug的symbols包含在这个文件中.
他有什么作用? 当release的版本 crash的时候,会有一个日志文件,包含出错的内存地址, 使用symbolicatecrash工具能够把日志和dSYM文件转换成可以阅读的log信息,也就是将内存地址,转换成程序里的函数或变量和所属于的 文件名.
将类似
Thread 0 Crashed:
0 libobjc.A.dylib 0×300c87ec 0×300bb000 + 55276
1 MobileLines 0×00006434 0×1000 + 21556
2 MobileLines 0×000064c2 0×1000 + 21698
3 UIKit 0×30a740ac 0×30a54000 + 131244
的log信息转换成
Thread 0 Crashed:
0 libobjc.A.dylib 0×300c87ec objc_msgSend + 20
1 MobileLines 0×00006434 -[BoardView setSelectedPiece:] (BoardView.m:321)
2 MobileLines 0×000064c2 -[BoardView touchesBegan:withEvent:] (BoardView.m:349)
3 UIKit 0×30a740ac -[UIWindow sendEvent:] + 264
的有用信息。
工具symbolicatecrash隐藏在/Developer/Platforms/iPhoneOS.platform/Developer /Library/Xcode/Plug-ins/iPhoneRemoteDevice.xcodeplugin/Contents/Resources/symbolicatecrash
所以一般复制到/usr/local/bin/ 成为命令行直接调用
$ sudo cp /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins/iPhoneRemoteDevice.xcodeplugin/Contents/Resources/symbolicatecrash /usr/local/bin/
这个时候运行
$ symbolicatecrash -h
就能看见帮助信息了.
这个时候,问题又来了..每次编译后的dsym文件都要手动保存一次,很是麻烦.
于是有人写了一个脚本,自动在编译后保存该文件.
请参考:
http://www.cimgf.com/2009/12/23/automatically-save-the-dsym-files/
脚本我复制过来在下面
#!/bin/sh
if [ "$BUILD_STYLE" == "Debug" ]; then
echo “Skipping debug”
exit 0;
fiif [ "$EFFECTIVE_PLATFORM_NAME" == "-iphonesimulator" ]; then
echo “Skipping simulator build”
exit 0;
fiSRC_PATH=${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}
RELATIVE_DEST_PATH=dSYM/${EXECUTABLE_NAME}.$(date +%Y%m%d%H%M%S).app.dSYM
DEST_PATH=${PROJECT_DIR}/${RELATIVE_DEST_PATH}
echo “moving ${SRC_PATH} to ${DEST_PATH}”mv “${SRC_PATH}” “${DEST_PATH}”
if [ -f ".git/config" ]; then
git add “${RELATIVE_DEST_PATH}”
git commit -m “Added dSYM file for ${BUILD_STYLE} build” “${RELATIVE_DEST_PATH}”
fi