What is the dSYM?


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;
fi

if [ "$EFFECTIVE_PLATFORM_NAME" == "-iphonesimulator" ]; then
echo “Skipping simulator build”
exit 0;
fi

SRC_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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM