最新消息:20181230 VPS服务器已从Linode换到腾讯云香港,主题仍用朋友推荐的大前端D8

[未解决]Bugly中上传符号表dSYM文件

iOS crifan 1757浏览 0评论

iOS符号表配置 – iOS堆栈还原_iOS日志分析_iOS dsym工具_iOS错误分析

现在先手动上传

Bugly SDK – Android SDK_iOS SDK_NDK_符号表工具

符号表工具

算了,还是去弄自动上传的,比较好用:

iOS符号表配置 – iOS堆栈还原_iOS日志分析_iOS dsym工具_iOS错误分析

(之前不小心,下载了android的符号表工具。。。)

现在去下载:iOS的符号表工具:

得到:buglySymboliOS.jar

然后放到个人目录的新建bin文件夹:

中:

下载

自动配置符号表 zip 文件

得到:

BuglydSYMUploader.zip

解压得到:

dSYMUpload.sh

内容为:

#!/bin/sh
# Copyright 2014-2016 Bugly, Tencent. All rights reserved.
#
# V1.2.1
#
# 2016.03.02
#
#
################################################################################
# # 注意: 请配置下面的信息
################################################################################
# BUGLY_APP_ID=”YOUR_APP_ID”
# BUGLY_APP_KEY=”YOUR_APP_KEY”
# BUNDLE_IDENTIFIER=”YOUR_BUNDLE_ID”
################################################################################
# # 自定义配置
################################################################################
# # Debug模式编译是否上传,1=上传 0=不上传,默认不上传
# UPLOAD_DEBUG_SYMBOLS=0
#
# # 模拟器编译是否上传,1=上传 0=不上传,默认不上传
# UPLOAD_SIMULATOR_SYMBOLS=0
#
# #只有Archive操作时上传, 1=支持Archive上传 0=所有Release模式编译都上传
# UPLOAD_ARCHIVE_ONLY=0
#
# # 脚本默认配置的版本格式为CFBundleShortVersionString(CFBundleVersion),  如果你修改默认的版本格式, 请设置此变量, 如果不想修改, 请忽略此设置
# CUSTOMIZED_APP_VERSION=””
#
#
#
# This script will extract symbols from the .dSYM and generate .symbol file(Bugly supported) and upload to server.
# You could visit http://bugly.qq.com to get more details about Bugly.(Optional: buylyweb.et.wsd.com)
#
# Usage:
#   * The instructions assume you have copyed this script into your project int Xcode.
#   * Copy the “buglySymbolIOS.jar” file into the “~/bin” folder.
#   * Open the project editor, select your build target.
#   * Click “Build Phases” at the top of the project editor.
#   * Click “+” button in the top left corner and select “New Run Script Phase”.
#   * Click “Run Script”.
#   * Paste the following script into the dark text box. You will have to uncomment the lines (remove the #) of course.
#
# — SCRIPT BEGINS ON NEXT LINE, COPY AND EDIT FROM THERE —
#
#
#
# — END OF SCRIPT —
################################################################################
# 注意: 如果你不知道此脚本的执行流程和用法,请不要随便修改!
################################################################################
# 退出执行并打印提示信息
exitWithMessage() {
    echo “——————————–“
    echo -e “${1}”
    echo “——————————–“
    echo “No upload and exit.”
    echo “—————————————————————-“
    exit ${2}
}
echo “—————————————————————-“
echo “Copyright 2014-2015 Bugly @Tencent. All rights reserved.”
echo “This script will extract symbols from the .dSYM file and generate .symbol file(Bugly supported) and upload to server.”
echo “You could visit http://bugly.qq.com to get more details about Bugly.”
echo “—————————————————————-“
echo “Uploading dSYM to Bugly.”
echo “”
# Bugly服务域名
DSYM_UPLOAD_DOMAIN=”bugly.qq.com”
# 读取Info.plist文件中的版本信息
echo “Info.Plist : ${INFOPLIST_FILE}”
BUNDLE_VERSION=$(/usr/libexec/PlistBuddy -c ‘Print CFBundleVersion’ “${INFOPLIST_FILE}”)
BUNDLE_SHORT_VERSION=$(/usr/libexec/PlistBuddy -c ‘Print CFBundleShortVersionString’ “${INFOPLIST_FILE}”)
# 组装Bugly默认识别的版本信息(格式为CFBundleShortVersionString(CFBundleVersion), 例如: 1.0(1))
if [ ! “${CUSTOMIZED_APP_VERSION}” ]; then
BUGLY_APP_VERSION=”${BUNDLE_SHORT_VERSION}(${BUNDLE_VERSION})”
else
BUGLY_APP_VERSION=”${CUSTOMIZED_APP_VERSION}”
fi
# Bugly符号提取工具路径, 请确保buglySymboliOS.jar的路径是正确的
BUGLY_SYMBOL_JAR_PATH=”${SRCROOT}/dsymtool/buglySymboliOS.jar”
if [ ! -f “${BUGLY_SYMBOL_JAR_PATH}” ]; then
    BUGLY_SYMBOL_JAR_PATH=”$HOME/bin/buglySymboliOS.jar”
fi
echo “——————————–“
echo “Step 1: Prepare application information.”
echo “——————————–“
echo “Product Name: ${PRODUCT_NAME}”
echo “Bundle Identifier: ${BUNDLE_IDENTIFIER}”
echo “Version: ${BUNDLE_SHORT_VERSION}”
echo “Build: ${BUNDLE_VERSION}”
echo “Bugly App ID: ${BUGLY_APP_ID}”
echo “Bugly App key: ${BUGLY_APP_KEY}”
echo “Bugly App Version: ${BUGLY_APP_VERSION}”
echo “——————————–“
echo “Step 2: Check the arguments …”
##检查模拟器编译是否允许上传符号
if [ “$EFFECTIVE_PLATFORM_NAME” == “-iphonesimulator” ]; then
if [ $UPLOAD_SIMULATOR_SYMBOLS -eq 0 ]; then
exitWithMessage “Warning: Build for simulator and skipping to upload. \nYou can modify ‘UPLOAD_SIMULATOR_SYMBOLS’ to 1 in the script.” 0
fi
fi
##检查是否是Release模式编译
if [ “${CONFIGURATION=}” == “Debug” ]; then
if [ $UPLOAD_DEBUG_SYMBOLS -eq 0 ]; then
    exitWithMessage “Warning: Build for debug mode and skipping to upload. \nYou can modify ‘UPLOAD_DEBUG_SYMBOLS’ to 1 in the script.” 0
fi
fi
##检查是否Archive操作
if [ $UPLOAD_ARCHIVE_ONLY -eq 1 ]; then
    if [[ “$TARGET_BUILD_DIR” == *”/Archive”* ]]; then
        echo “Archive the package”
    else
        exitWithMessage “Warning: Build for NOT Archive mode and skipping to upload. \nYou can modify ‘UPLOAD_ARCHIVE_ONLY’ to 0 in the script.” 0
    fi
fi
# 检查必须参数是否设置
if [ ! “${BUGLY_APP_ID}” ]; then
exitWithMessage “Error: Bugly App ID not defined. Please set ‘BUGLY_APP_ID’ ” 0
fi
if [[ “${BUGLY_APP_ID}” == *”App ID”* ]]; then
exitWithMessage “Error: Bugly App ID not defined.” 0
fi
if [ ! “${BUGLY_APP_KEY}” ]; then
exitWithMessage “Error: Bugly APP Key not defined.” 0
fi
if [ ! “${BUNDLE_IDENTIFIER}” ]; then
exitWithMessage “Error: Bundle Identifier not defined.” 0
fi
function uploadDSYM {
    DSYM_SRC=”$1″
    echo “.dSYM file: ${DSYM_SRC}”
    if [ ! -d “$DSYM_SRC” ]; then
    exitWithMessage “dSYM source not found: ${DSYM_SRC}” 0
    fi
    DSYM_FILE_NAME=${DSYM_SRC##*/}
    DSYM_SYMBOL_OUT_ZIP_NAME=”${DSYM_FILE_NAME}.bSymbol.zip”
    # 替换空格
    DSYM_SYMBOL_OUT_ZIP_NAME=”${DSYM_SYMBOL_OUT_ZIP_NAME// /_}”
    # 声明符号表临时目录和备份目录
    DSYM_ZIP_OUT_DIR=${BUILD_DIR}/BuglySymbolsTemp
    DSYM_SYMBOL_BACKUP_DIR=${BUILD_DIR}/BuglySymbolsBackup
    if [ ! -e “${DSYM_ZIP_OUT_DIR}” ]; then
        mkdir ${DSYM_ZIP_OUT_DIR}
    fi
    if [ ! -e “${DSYM_SYMBOL_BACKUP_DIR}” ]; then
        mkdir ${DSYM_SYMBOL_BACKUP_DIR}
    fi
    # 备份并清理
    find ${DSYM_ZIP_OUT_DIR} -name “*.bSymbol.zip” -print0 | xargs -0 -I {} mv {} ${DSYM_SYMBOL_BACKUP_DIR}
    /bin/rm -rf “${DSYM_ZIP_OUT_DIR}/*.bSymbol.zip”
    DSYM_ZIP_FPATH=”${DSYM_ZIP_OUT_DIR}/${DSYM_SYMBOL_OUT_ZIP_NAME}”
    # 提取符号信息
    echo “——————————–“
    echo “Step 3: Extract symbol info from .dSYM file. to ${DSYM_ZIP_FPATH}”
    if [ ! -f “$BUGLY_SYMBOL_JAR_PATH” ]; then
        exitWithMessage “Error: Jar file ‘${BUGLY_SYMBOL_JAR_PATH}’ was not found. \nPlease copy the jar file into ~/bin folder.” 1
    fi
    echo “——————————–“
        (/usr/bin/java -jar “${BUGLY_SYMBOL_JAR_PATH}” -i “${DSYM_SRC}” -o “${DSYM_ZIP_FPATH}” ) || exitWithMessage “Error: Failed to extract symbols.” 1
    echo “——————————–“
    if [ ! -e “${DSYM_ZIP_FPATH}” ]; then
        DSYM_SYMBOL_OUT_ZIP_NAME=$(ls ${DSYM_ZIP_OUT_DIR} | grep “.bSymbol.zip”)
        DSYM_ZIP_FPATH=”${DSYM_ZIP_OUT_DIR}/${DSYM_SYMBOL_OUT_ZIP_NAME}”
        DSYM_SYMBOL_OUT_ZIP_NAME=${DSYM_SYMBOL_OUT_ZIP_NAME//&/_}
    fi
    if [ ! -e “${DSYM_ZIP_FPATH}” ] ; then
        exitWithMessage “no symbol file zip archive generated: ${DSYM_ZIP_FPATH}” 0
    fi
    echo “Step 4: Upload the symbols of dSYM.”
    echo “——————————–“
    echo “zip : ${DSYM_SYMBOL_OUT_ZIP_NAME}”
    echo “dir : ${DSYM_ZIP_FPATH}”
    echo “dSYM upload domain: ${DSYM_UPLOAD_DOMAIN}”
    DSYM_UPLOAD_URL=”http://${DSYM_UPLOAD_DOMAIN}/upload/dsym?app=${BUGLY_APP_ID}&pid=2&ver=${BUGLY_APP_VERSION}&n=${DSYM_SYMBOL_OUT_ZIP_NAME}&key=${BUGLY_APP_KEY}&bid=${BUNDLE_IDENTIFIER}”
    echo “dSYM upload url: ${DSYM_UPLOAD_URL}”
    # Upload dSYM to Bugly
    echo “curl –header “Content-Type:application/zip” –data-binary “@${DSYM_ZIP_FPATH}” “${DSYM_UPLOAD_URL}” –verbose”
    echo “——————————–“
    STATUS=$(/usr/bin/curl –header “Content-Type:application/zip” –data-binary “@${DSYM_ZIP_FPATH}” “${DSYM_UPLOAD_URL}” –verbose)
    echo “——————————–“
    UPLOAD_RESULT=”FAILTURE”
    echo “Bugly server response: ${STATUS}”
    if [ ! “${STATUS}” ]; then
        echo “Error: Failed to upload the zip archive file.”
    elif [[ “${STATUS}” == *”:true”* ]]; then
        echo “Success to upload the dSYM for the app [${BUNDLE_IDENTIFIER} ${BUGLY_APP_VERSION}]”
        UPLOAD_RESULT=”SUCCESS”
    else
        echo “Error: Failed to upload the zip archive file to Bugly.”
    fi
    #Remove temp dSYM archive
    echo “Remove temporary zip archive: ${DSYM_ZIP_FPATH}”
            #/bin/rm -f “${DSYM_ZIP_FPATH}”
    if [ “$?” -ne 0 ]; then
        exitWithMessage “Error: Failed to remove temporary zip archive.” 0
    fi
    echo “——————————–“
    echo “${UPLOAD_RESULT} – dSYM upload complete.”
    if [[ “${UPLOAD_RESULT}” == “FAILTURE” ]]; then
        echo “——————————–“
        echo “Failed to upload the dSYM”
        echo “Please check the script and try it again.”
    fi
    echo “—————————————————————-“
}
# .dSYM文件信息
DSYM_FOLDER=”${DWARF_DSYM_FOLDER_PATH}”
IFS=$’\n’
echo “Scaning dSYM FOLDER: ${DSYM_FOLDER} …”
RET=”F”
for dsymFile in $(find “$DSYM_FOLDER” -name ‘*.dSYM’); do
    RET=”T”
    echo “Found dSYM file: $dsymFile”
    uploadDSYM $dsymFile
done
if [ $RET = “F” ]; then
    exitWithMessage “No .dSYM found in ${DSYM_FOLDER}” 0
fi

拷贝到Xcode的脚本中:

去配置对应的信息:

bugly的App Id:

/* Bugly
 * Crash Log Service
 */
let SalesAppBuglyId:String = “900038066”

App Key:

新版的bugly管理平台中,竟然找不到app的bundle id:

以及旧版中能找到呢,结果也找不到:

-》

最后还是去Xcode中找到了:

App的bundle identifier:

然后去配置如下:

################################################################################
# # 注意: 请配置下面的信息
################################################################################
BUGLY_APP_ID=”900038066″
BUGLY_APP_KEY=”kJXXGtVTGu2aZS9l”
BUNDLE_IDENTIFIER=”com.qorosauto.QorosSalesApp”
################################################################################
# # 自定义配置
################################################################################
# # Debug模式编译是否上传,1=上传 0=不上传,默认不上传
UPLOAD_DEBUG_SYMBOLS=1
#
# # 模拟器编译是否上传,1=上传 0=不上传,默认不上传
# UPLOAD_SIMULATOR_SYMBOLS=0
#
# #只有Archive操作时上传, 1=支持Archive上传 0=所有Release模式编译都上传
UPLOAD_ARCHIVE_ONLY=0
#
# # 脚本默认配置的版本格式为CFBundleShortVersionString(CFBundleVersion),  如果你修改默认的版本格式, 请设置此变量, 如果不想修改, 请忽略此设置
# CUSTOMIZED_APP_VERSION=””
#

如图:

然后去测试崩溃:

            //test crash then bugly show log with auto uploaded symbol
            let emptyList = [String]()
            gLog.info(“this line should crash: emptyList[0]=\(emptyList[0])”)

用真机iPhone连接到Mac的Xcode

Xcode去Run,调试运行app到iPhone,然后去点击,测试崩溃

看看bugly后台,是否可以自动上传符号表,显示错误信息时是否可以精确定位到行

然后此处调试安装app期间,就可以看到,在运行该脚本(有点耗时)

结果故意制造的崩溃,去查看,还是没有上传符号表:

还是无法精确定位错误。。。

注:此处的mac中的java版本,是大于java6的java7:

licrifandeMacBook-Pro:SalesAppiOS crifan$ java -version
java version “1.7.0_79”
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
licrifandeMacBook-Pro:SalesAppiOS crifan$ javac -version
javac 1.7.0_79

转载请注明:在路上 » [未解决]Bugly中上传符号表dSYM文件

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
62 queries in 0.072 seconds, using 9.48MB memory